1
I have a main class, through it I call a layout with listview
, and depending on the click, opens a different screen with different customer data.
Follow a piece of code:
public OnItemClickListener chamaAtividades(){
return(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> av, View v, int position, long id) {
Intent intent;
switch(position){
case 0:
setContentView(R.layout.atividade1);
TextView b = (TextView) findViewById(R.id.barra);
b.setText(new String("Gastronomia"));
ImageView iv = (ImageView) findViewById(R.id.iv);
iv.setImageResource(R.drawable.acai3);
TextView t1 = (TextView) findViewById(R.id.t1);
t1.setText(new String("Açaí da Praça"));
TextView t2 = (TextView) findViewById(R.id.t2);
t2.setText(new String("Texto descritivo do acai !"));
Linkify.addLinks(t2, Linkify.ALL);
TextView t3 = (TextView) findViewById(R.id.t3);
t3.setText(new String("(035)3341-6969"));
Linkify.addLinks(t3, Linkify.ALL);
TextView t4 = (TextView) findViewById(R.id.t4);
t4.setText(new String("www.acaidapraca.com"));
Linkify.addLinks(t4, Linkify.ALL);
TextView t5 = (TextView) findViewById(R.id.t5);
t5.setText(new String("[email protected]"));
Linkify.addLinks(t5, Linkify.ALL);
TextView t6 = (TextView) findViewById(R.id.t6);
t6.setText(new String("facebook.com/acaidapraca"));
Linkify.addLinks(t6, Linkify.ALL);
...
In this example by clicking on button 1 (case 0
) will call the layout atividade1
and set the texts and images above.
Within atividade1.xml
has a button and wanted to give an action to that button to call another class. How do I do this?
I was trying at the end of this code to implement something like this:
...
TextView t6 = (TextView) findViewById(R.id.t6);
t6.setText(new String("facebook.com/acaidaporra"));
Linkify.addLinks(t6, Linkify.ALL);
Button botao = (Button) findViewById(R.id.voltar);
botao.setOnClickListener(new View.OnClickListener() {
new Mapa().setVisible(true);
...
But it didn’t work.