0

我已经使用自定义适配器在 android 中实现了列表视图。在每个有两个或多个字段。我想获得点击的特定字段。怎么可能?任何帮助表示赞赏。

4

3 回答 3

0

 setOnItemClickListener 

在列表视图上。例如

listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,long id) {

                //"Here you will get the position on which you have clicked"
// and if you want the item at that position you have to **adapter.getItem(position)**
            }



    });

看看它是否适合你

于 2012-08-29T12:11:46.850 回答
0

尝试这个 :

     lstvw.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) {
                          String selectedFromList =   (String) lstvw.getItemAtPosition(myItemInt);

                          System.out.println("array:> > >  > > > >========================>"+selectedFromList);
                      }

                  });
于 2012-08-29T12:16:13.230 回答
0

您需要实现 OnItemClickListener 并覆盖 onItemClick 方法。像这样覆盖 onItemClick 方法:

@Override
public void onItemClick(AdapterView<?> adapter, View view, int position,
        long id) {
    yourList.get(position);//This will give you object on specfic pisition clicked
    Intent myIntent = new Intent(getBaseContext(), classToCallOnClick.class);
    .  
              .  
              .  
              .
}  

希望对你有帮助.....

于 2012-08-29T12:20:45.290 回答