2011-10-28 21 views
0

リストビューにあるアイテムを他のアクティビティにリンクしたいので、リストビューアイテムをクリックすると他のアクティビティに移動できます。このリストビューのクリック可能なアイテムを他のアクティビティにリダイレクトするにはどうすればよいですか?

setListAdapter(new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, Categories)); 
    ListView lv = getListView(); 
    lv.setTextFilterEnabled(true); 
    lv.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView<?> parent, View v,int position, long id) { 

      switch (position){ 
      case 0: Intent animalsGridViewIntent = new Intent(ListOfAppGallery.this,AnimalsGridView.class);  
        ListOfAppGallery.this.startActivity(animalsGridViewIntent); 
        break; 
      case 1: Intent calenderGridViewIntent = new Intent(ListOfAppGallery.this,CalenderGridView.class);  
        ListOfAppGallery.this.startActivity(calenderGridViewIntent); 
        break; 
      case 2: Intent carsGridViewIntent = new Intent(ListOfAppGallery.this,CarsGridView.class);  
        ListOfAppGallery.this.startActivity(carsGridViewIntent); 
        break; 
      } 
     } 
    });  

答えて

1

使用は、活動のためのListViewコントロールとimplenment OnItemClickListenerためlist.setOnItemClickListener(this);を追加します。

と別のアクティビティには、このメソッドをオーバーライド:

@Override

public void onItemClick(AdapterView<?> arg0, View v, final int position,long arg3) 
    { 
    Intent in=new Intent(YourActivity.this,NewClass.class); 
      startActivity(in); 
      finish(); 

    } 

あなたはpolamReddy.itが働い

+0

感謝をしたいに応じて位置を確認してください。 –

+0

ようこそ... –

関連する問題