我如何在listview上执行onclick操作?

时间:2010-12-31 12:39:57

标签: android listview android-edittext

   I have designed a custom listview. In that view i have one textview and two edittext fields. when i am clicking on the individual rows in listview that perform another activity(i.e another page will open). But i cannot perform onclick action on my listview.

我写了一些代码,但它没有用。我已经显示了如下代码。

public void onCreate(Bundle savedInstanceState){
       super.onCreate(savedInstanceState);
       setContentView(R.layout.sharefolioedit);

       getList();
           lv.setAdapter(new EfficientAdapter(this));
            lv = getListView();
    lv.setClickable(true);
             lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      public void onItemClick(AdapterView<?> parentView, View childView,
      int position, long id) {
      Intent intent = new Intent(CategoryList.this,AddSubCategoryList.class);
      startActivity(intent);

      }

       }

1 个答案:

答案 0 :(得分:0)

这对我来说很好:

this.setListAdapter(new EfficientAdapter(this));
this.getListView().setOnItemClickListener ( new AdapterView. OnItemClickListener ( )
{
    public void onItemClick ( AdapterView <?> aView, View v, int position, long id )
    {
        Intent intent = new Intent(CategoryList.this,AddSubCategoryList.class);
        startActivity(intent);
    }
});