我試圖在用戶點擊listview
中的一個項目時開始一個活動。在下面的適配器中,我在intent
和onClick中遇到了問題。什麼可能導致失敗? 確定更新後代碼是否缺失}};}}字符就像編輯我的代碼之後一樣listview startactivty on click item
我的代碼 return rowView;
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
int itemPosition = position;
String itemValue= (String)listView.getItemAtPosition(position);
if (itemValue.equals("1")){
Intent intent = new Intent(context, Spain.class);
context.startActivity(intent);}
else if (itemValue.equals("2")) {
Intent intent = new Intent(context, As.class);
context.startActivity(intent);}
else if(itemValue.equals("3")){
Intent intent = new Intent(context, Ma.class);
context.startActivity(intent);}
else if(itemValue.equals("4")) {
Intent intent = new Intent(context, Me.class);
context.startActivity(intent);}
else if (itemValue.equals("5")){
Intent intent = new Intent(context, Gr.class);
context.startActivity(intent);}
else if(itemValue.equals("6")) {
Intent intent = new Intent(context, Th.class);
context.startActivity(intent);}
else if(itemValue.equals("7")) {
Intent intent = new Intent(context, Ukr.class);
context.startActivity(intent);}
else if (itemValue.equals("8")){
Intent intent = new Intent(context, Po.class);
context.startActivity(intent);}
else if (itemValue.equals("9")) {
Intent intent = new Intent(context, France.class);
context.startActivity(intent);}
else if (itemValue.equals("10")){
Intent intent = new Intent(context, UK.class);
context.startActivity(intent);}
else if (itemValue.equals("11")) {
Intent intent = new Intent(context, Ksa.class);
context.startActivity(intent);}
else if (itemValue.equals("12")) {
Intent intent = new Intent(context, Ger.class);
context.startActivity(intent);}
else if (itemValue.equals("13")) {
Intent intent = new Intent(context, Canda.class);
context.startActivity(intent);}
else if (itemValue.equals("14")){
Intent intent = new Intent(context, Turkey.class);
context.startActivity(intent);}
else if (itemValue.equals("15")) {
Intent intent = new Intent(context, Italy.class);
context.startActivity(intent);}
else if (itemValue.equals("16")) {
Intent intent = new Intent(context, Russia.class);
context.startActivity(intent);}
else if (itemValue.equals("17")) {
Intent intent = new Intent(context, China.class);
context.startActivity(intent);}
else if (itemValue.equals("18")) {
Intent intent = new Intent(context, Usa.class);
context.startActivity(intent);}
})};}
「我得到了問題」 - 你有什麼問題? – Ajoy
選擇列表項時出現任何錯誤? – Sony