我如何在列表视图上执行 onclick 操作?

发布于 2024-10-10 11:34:07 字数 937 浏览 1 评论 0原文

   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);

      }

       }
   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.

i have wrote some code but its not working. i have shown that code as below.

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);

      }

       }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凯凯我们等你回来 2024-10-17 11:34:08

这对我来说效果很好:

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);
    }
});  

This is working fine for me :

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);
    }
});  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文