У меня проблема с отображением списка нажатий. Когда я нажимаю на кнопку, ничего не происходит. Я должен начать новую деятельность.Listview onclick issue
Я хочу знать, что случилось с моим кодом:
Импорт
public class CountriesListAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
ListView listView ;
public CountriesListAdapter(Context context, String[] values) {
super(context, R.layout.country_list_item, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.country_list_item, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.txtViewCountryName);
ImageView imageView = (ImageView) rowView.findViewById(R.id.imgViewFlag);
String g=values[position];
textView.setText((g).trim());
if (g.equals("1")) {
imageView.setImageResource(R.drawable.ger);
} else if (g.equals("2")) {
imageView.setImageResource(R.drawable.ukra);
} else if (g.equals("3")) {
imageView.setImageResource(R.drawable.k);
} else if (g.equals("4")) {
imageView.setImageResource(R.drawable.wf);
}
return rowView;}
protected void onListItemClick(int position, View convertView, ViewGroup parent) {
String g=values[position];
if (g.equals("4")){
Intent intent = new Intent(context, Spain.class);
context.startActivity(intent);
}}
}
где вы реализуете 'onListItemClick'? –
Какая кнопка? Вы имели в виду список? – async
button или listview? – Rob