Professional Documents
Culture Documents
SISTEMAS DE INFORMAO
SANTO ANDR
2015
SANTO ANDR
2015
2
RESUMO
SUMRIO
Resumo.................................................................................................................................... 03
ETAPA 1..................................................................................................................................05
Passo 3 - Relatrio 1.3 .............................................................................................05
ETAPA 2 .................................................................................................................................16
Passo 3 - Relatrio 2.3 .............................................................................................16
ETAPA 3 .................................................................................................................................22
Passo 3 - Relatrio 3.3 .............................................................................................22
ETAPA 4 .................................................................................................................................38
Passo 3 - Relatrio 4.3 .............................................................................................38
Concluso.................................................................................................................................39
Bibliografia..............................................................................................................................39
ETAPA 1______________________________________________
Passo 3 - Relatrio 1.3 Entregar um relatrio contendo todo cdigo fonte gerado no Passo 2.
Implementar a classe Desejo conforme diagrama abaixo:
this.categoria = categoria;
}
<Button
android:id= " @ + id / button_detalharP "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / detalhar_p " />
</LinearLayout>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/salvar" />
</LinearLayout>
<TextView
android:id= " @ + id / show_lojas "
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= " @string / show_lojas "
android:visibility= " invisible " />
</LinearLayout>
12
android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/preco_maximo" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_width= " match_parent "
android:layout_height= " wrap_content "
android:text= "@string/lojas" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/salvar" />
</LinearLayout>
14
Resources
<? xml version = " 1.0 " encoding= " utf -8 " ?>
<resources>
<string name= " app_name " >Lista de Desejos</string>
<string name= " name_produto " > Nome do Produto </string>
<string name= " categoria " > Categoria </string>
<string name= " preco_minimo " > Preo Mnimo </string>
<string name= " preco_maximo " > Preo Mximo </string>
<string name= " lojas " > Lojas </string>
<string name= " salvar " >Salvar</string>
<string name= " criar_p " > Ciar Desejo </string>
<string name= " alterar_p " > Alterar Desejo </string>
<string name= " detalhar_p " > Detalhar Desejo </string>
</resources>
15
ETAPA 2______________________________________________
Passo 3 Relatrio 2.3 Contedo do cdigo fonte gerado no Passo 2.
Usar Intents para programar a navegao entre as Activities criadas na etapa anterior:
package br.com.Lista.de.Desejos;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
16
17
package br.com.Lista.de.Desejos;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}
18
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.button_alterarP);
19
package br.com.Lista.de.Desejos;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}
20
package br.com.Lista.de.Desejos;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.second);
}
}
21
ETAPA 3______________________________________________
Passo 3 Relatrio 3.3 Contedo do cdigo fonte gerado no Passo 2.
ListarDesejos Deve ser capaz de consultar todos os desejos cadastrados no banco
de dados e exibir na Activity atravs de um ListView (ou similar).
AdicionarDesejo Deve ser capaz de incluir um desejo no banco de dados.
DetalharDesejo Deve ser capaz de exibir os detalhes do Desejo. A partir dessa
Activity, deve ser possvel ir para a Activity Alterar Desejo e acionar a funcionalidade
Excluir Desejo.
AlterarDesejo Deve ser capaz de alterar os dados de um Desejo previamente
cadastrado no banco de dados.
Programar a funcionalidade Excluir Desejo Deve ser capaz de excluir um desejo
previamente cadastrado no banco de dados.
ListarDesejo.java
package br.com.Lista.de.Desejos;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
22
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.LinearLayout.ListarDesejo);
obj = (ListView)findViewById(R.id.listView1);
obj.setAdapter(arrayAdapter);
obj.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
23
intent.putExtras(dataBundle);
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
super.onOptionsItemSelected(item);
switch(item.getItemId())
{
case R.id.item1:Bundle dataBundle = new Bundle();
dataBundle.putInt("id", 0);
startActivity(intent);
24
return true;
default:
return super.onOptionsItemSelected(item);
}
}
25
DetalharDesejo.java
package br.com.Lista.de.Desejos;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
TextView show_nome ;
TextView show_categoria;
TextView show_preco_minimo;
TextView show_preco_maximo;
TextView show_lojas;
int id_To_Update = 0;
26
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.LinearLayout.ListarDesejo);
show_nome = (TextView) findViewById(R.id.editTextshow_nome);
show_categoria = (TextView) findViewById(R.id.editTextshow_categoria);
show_preco_minimo = (TextView)
findViewById(R.id.editTextshow_preco_maximo);
show_preco_maximo = (TextView)
findViewById(R.id.editTextshow_preco_minimo);
show_lojas = (TextView) findViewById(R.id.editTextshow_lojas);
if(Value>0){
Cursor rs = mydb.getData(Value);
id_To_Update = Value;
rs.moveToFirst();
String show_nom =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_nome));
27
String show_categori =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_categori
a));
String show_preco_minim =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_preco_m
inimo));
String show_preco_maxim =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOS_COLUMN_show_preco_m
aximo));
String show_loja =
rs.getString(rs.getColumnIndex(OperadorBancoDados.DESEJOSS_COLUMN_show_lojas));
if (!rs.isClosed())
{
rs.close();
}
Button b = (Button)findViewById(R.id.button1);
b.setVisibility(View.INVISIBLE);
show_nome.setText((CharSequence)show_nom);
show_nome.setFocusable(false);
show_nome.setClickable(false);
show_categoria.setText((CharSequence)show_categori);
show_categoria.setFocusable(false);
show_categoria.setClickable(false);
show_preco_minimo.setText((CharSequence)show_preco_minim);
show_preco_minimo.setFocusable(false);
show_preco_minimo.setClickable(false);
28
show_preco_maximo.setText((CharSequence)show_preco_maxim);
show_preco_maximo.setFocusable(false);
show_preco_maximo.setClickable(false);
show_lojas.setText((CharSequence)show_loja);
show_lojas.setFocusable(false);
show_lojas.setClickable(false);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if(extras !=null)
{
int Value = extras.getInt("id");
if(Value>0){
getMenuInflater().inflate(R.menu.DetalharDesejo, menu);
}
else{
getMenuInflater().inflate(R.menu.ListarDesejo, menu);
}
29
}
return true;
}
show_categoria.setEnabled(true);
show_categoria.setFocusableInTouchMode(true);
show_categoria.setClickable(true);
show_preco_minimo.setEnabled(true);
show_preco_minimo.setFocusableInTouchMode(true);
show_preco_minimo.setClickable(true);
show_preco_maximo.setEnabled(true);
show_preco_maximo.setFocusableInTouchMode(true);
show_preco_maximo.setClickable(true);
30
show_lojas.setEnabled(true);
show_lojas.setFocusableInTouchMode(true);
show_lojas.setClickable(true);
return true;
case R.id.Delete_Desejo:
}
});
AlertDialog d = builder.create();
d.setTitle("Are you sure");
d.show();
31
return true;
default:
return super.onOptionsItemSelected(item);
}
}
else{
if(mydb.insertDesejo(show_nome.getText().toString(),
show_categoria.getText().toString(), show_preco_minimo.getText().toString(),
show_preco_maximo.getText().toString(), show_lojas.getText().toString())){
Toast.makeText(getApplicationContext(), "done",
Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), "not done",
Toast.LENGTH_SHORT).show();
}
Intent intent = new
Intent(getApplicationContext(),com.example.addressbook.MainActivity.class);
startActivity(intent);
}
}
}
}
33
OperadorBancoDados.java
package com.example.addressbook;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteOperadorBancoDados;
import android.database.sqlite.SQLiteDatabase;
34
36
while(res.isAfterLast() == false){
array_list.add(res.getString(res.getColumnIndex(DESEJOS_COLUMN_NAME)));
res.moveToNext();
}
return array_list;
}
}
37
ETAPA 4______________________________________________
Passo 3 Relatrio 4.3 Contedo do cdigo fonte gerado no Passo 2.
<item
android:id="@+id/menu_item_share"
android:showAsAction="ifRoom"
android:title="Share"
android:actionProviderClass="android.widget.ShareActionProvider"
/>
------------------------------------------------------------------------
return true;
}
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
38
CONCLUSO
O contedo exposto o resultado do desenvolvimento proposto na ATPS. Os
exemplos implementados foram feitos com a ajuda do contedo proposto pela atps e tambm
sites na internet. Contedo este, que foi fundamental para o desenvolvimento dos exemplos.
BIBLIOGRAFIA
Livro k19 k41. Desenvolvimento mobile com android.
LEE, Wei Meng. Introduo ao Desenvolvimento de Aplicativos para o Android. 1
ed. So Paulo: Cincia Moderna, 2011.
SANTOS, Rafael. Introduo Programao Orientada a Objeto Utilizando Java. 1
ed. Rio de Janeiro: Campus - Elsevier, 2003, v.1.
DEITEL, P. J.; DEITEL, Harvery M.. C: Como Programar. 6 ed. So Paulo: Pearson,
2011.
CADENHEAD, Rogers. Aprenda em 21 dias Java 2. 4 ed. Rio de Janeiro: Elsevier,
2005.
RESENDE, Antnio Maria Pereira. Programao Orientada a Aspectos em Java:
Desenvolvimento de Software Orientado a Aspectos. 1 ed. Rio de Janeiro: Brasport, 2005.
NIEMEYER, Patrick. Aprendendo Java 2 SDK: verso 1.3. 1 ed. Rio de Janeiro:
Campus, 2000.
TUTORIAL Android Parte 3 Construo de Telas por Renan Drabach
< http://www.mobiltec.com.br/blog/index.php/tutorial-android-parte-3-construcao-de-telas/ >
Acesso em: 04 Abril. 2015
Android Developers Training por Google
< http://developer.android.com/training/index.html >
Acesso em: 04 Abril. 2015
Android - SQLite Database Tutorial
< http://www.tutorialspoint.com/android/android_sqlite_database.htm >
39