-
-
Save rafaeltoledo/47fc5e132e51937f94df32af584cfbdc to your computer and use it in GitHub Desktop.
Android 03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.rafaeltoledo.restaurante; | |
import net.rafaeltoledo.restaurante.model.Restaurante; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.RadioGroup; | |
public class ListaRestaurantes extends Activity { | |
Restaurante r = new Restaurante(); | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
Button salvar = (Button) findViewById(R.id.salvar); | |
salvar.setOnClickListener(onSave); | |
} | |
private OnClickListener onSave = new OnClickListener() { | |
public void onClick(View arg0) { | |
EditText nome = (EditText) findViewById(R.id.nome); | |
EditText endereco = (EditText) findViewById(R.id.end); | |
r.setNome(nome.getText().toString()); | |
r.setEndereco(endereco.getText().toString()); | |
RadioGroup tipos = (RadioGroup) findViewById(R.id.tipos); | |
switch (tipos.getCheckedRadioButtonId()) { | |
case R.id.rodizio: | |
r.setTipo("rodizio"); | |
break; | |
case R.id.fast_food: | |
r.setTipo("fast_food"); | |
break; | |
case R.id.a_domicilio: | |
r.setTipo("a_domicilio"); | |
break; | |
} | |
} | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:stretchColumns="1"> | |
<TableRow> | |
<TextView android:text="Nome:" /> | |
<EditText android:id="@+id/nome" /> | |
</TableRow> | |
<TableRow> | |
<TextView android:text="Endereço:" /> | |
<EditText android:id="@+id/end" /> | |
</TableRow> | |
<TableRow> | |
<TextView android:text="Tipo:"/> | |
<RadioGroup android:id="@+id/tipos"> | |
<RadioButton | |
android:id="@+id/rodizio" | |
android:text="Rodízio" /> | |
<RadioButton | |
android:id="@+id/fast_food" | |
android:text="Fast Food" /> | |
<RadioButton | |
android:id="@+id/a_domicilio" | |
android:text="A Domicílio" /> | |
</RadioGroup> | |
</TableRow> | |
<Button | |
android:id="@+id/salvar" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="Salvar" /> | |
</TableLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
android:stretchColumns="1"> | |
<TableRow> | |
<TextView android:text="Nome:" /> | |
<EditText android:id="@+id/nome" /> | |
</TableRow> | |
<TableRow> | |
<TextView android:text="Endereço:" /> | |
<EditText android:id="@+id/end" /> | |
</TableRow> | |
<Button android:id="@+id/salvar" | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="Salvar" /> | |
</TableLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.rafaeltoledo.restaurante.model; | |
public class Restaurante { | |
private String nome = ""; | |
private String endereco = ""; | |
private String tipo = ""; | |
public String getNome() { | |
return nome; | |
} | |
public void setNome(String nome) { | |
this.nome = nome; | |
} | |
public String getEndereco() { | |
return endereco; | |
} | |
public void setEndereco(String endereco) { | |
this.endereco = endereco; | |
} | |
public String getTipo() { | |
return tipo; | |
} | |
public void setTipo(String tipo) { | |
this.tipo = tipo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment