1
I have a list of customers. I would like when I click on a customer to open a new website. But I did something wrong. Follows the codes:
list.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(ClienteActivity.this, DetalhesCatalogo.class);
startActivity(intent);
}
});
}
When I spin it makes the following mistake:
09-16 13:13:25.047 1532-1532/com.example.jnior.decorus E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.jnior.decorus, PID: 1532
*java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxxxxxxxxxxxxxxxxxxxxxx.ClienteActivity}:
java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead*
Already in error: Don’t call setOnClickListener for an Adapterview. You probably want setOnItemClickListener Instead Do not call setOnClickListener. Calls setOnItemClickListener.
– Mr_Anderson
But then I have to change the code, because if you put setOnItemClickListener it gives error.
– Artur Mafezzoli Júnior
Look down there at the answer
– Mr_Anderson
just give listview.setOnItem (and hit enter that auto-complete android studio. then just put the Intent in the middle of the click)
– Mr_Anderson
Shut up man. Thank you. ABS.
– Artur Mafezzoli Júnior
brand as sure. I thank you.
– Mr_Anderson