将描述从列表视图项中保存。

| 我需要将描述保存在ListView上所选项目的字符串中。 我怎样才能做到这一点?     
已邀请:
如果您有简单的列表项,则必须在Activity类中声明String变量,并注册itemclick事件以侦听项目的点击。 这就是我的做法:
 class YourActivity extends Activity{
     String my_selected_item_text=null;

    @override
    protected void onCreate(Bundle savedInstanceState)
    {
          //your stuffs here
          yourlistview.setOnItemClickListener(
          new OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View view, int position,
                long arg3) {
               my_selected_item_text=(String)yourlistview.getItemAtPosition(position);
              //my_selected_item_text contains description of the String displayed in your ListView. now you can save that description anywhere you want....
         });
    }
 }
    
我的第一个想法是,您可以在列表视图中使用活动的字符串成员变量     

要回复问题请先登录注册