Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在listview中单击列表项时调用新的类视图?_Android_Listview - Fatal编程技术网

Android 如何在listview中单击列表项时调用新的类视图?

Android 如何在listview中单击列表项时调用新的类视图?,android,listview,Android,Listview,我正在用android开发一个应用程序,我必须在列表视图中单击一个项目时调用一个类。我已经为它开发了类,但单击时不调用类视图。我不明白为什么 下面是我要调用的类的代码 public void onItemClick(AdapterView parent, View v, int position, long id) { Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");

我正在用android开发一个应用程序,我必须在列表视图中单击一个项目时调用一个类。我已经为它开发了类,但单击时不调用类视图。我不明白为什么

下面是我要调用的类的代码

public void onItemClick(AdapterView parent, View v, int position, long id)
     {
         Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");

         Intent itemintent = new Intent(this,ShowDescription.class);

         Bundle b = new Bundle();
         b.putString("title", feed.getItem(position).getTitle());
         b.putString("description", feed.getItem(position).getDescription());
         b.putString("link", feed.getItem(position).getLink());
         b.putString("pubdate", feed.getItem(position).getPubDate());

         itemintent.putExtra("android.intent.extra.INTENT", b);

         startSubActivity(itemintent,0);
     }


    private void startSubActivity(Intent itemintent, int i) {
        // TODO Auto-generated method stub

    }

和thanx提前

将您的代码更改为此

public void onItemClick(AdapterView parent, View v, int position, long id)
{
ListView feed = (ListView) findViewById(R.id.yourID);
Intent itemintent = new Intent(this,ShowDescription.class);

 itemintent.putExtra("title", feed.getItemAtPosition(position).getTitle());
 itemintent.putExtra("description", feed.getItemAtPosition(position).getDescription());
 itemintent.putExtra("link", feed.getItemAtPosition(position).getLink());
 itemintent.putExtra("pubdate", feed.getItemAtPosition(position).getPubDate());

 startActivity(itemintent);
}

我希望“提要”这是您的列表视图。如果要在下一个活动中获取值,请使用以下命令:-

 Bundle extra= getIntent().getExtras();
 String title = extra.getString("title");
 String description = extra.getString("description");
 String link = extra.getString("link");
 String pubdate = extra.getString("pubdate");
这会有帮助的。。如果问题仍然存在,请回答。

listview.setOnItemClickListener(新建OnItemClickListener()){
listview.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                        long arg3) {


                    Intent arDetail = new Intent(this,ShowDescription.class);
                    arDetail.putString("title", feed.getItem(position).getTitle());
    arDetail.putString("description", feed.getItem(position).getDescription());
    arDetail.putString("link", feed.getItem(position).getLink());
   arDetail.putString("pubdate", feed.getItem(position).getPubDate());
                    startActivity(arDetail);

                }
            });
@凌驾 公共链接(AdapterView arg0、视图arg1、内部arg2、, 长arg3){ Intent arDetail=新的Intent(这是ShowDescription.class); putString(“title”,feed.getItem(position.getTitle()); putString(“description”,feed.getItem(position.getDescription()); putString(“link”,feed.getItem(position.getLink()); putString(“pubdate”,feed.getItem(position.getPubDate()); 星触觉(arDetail); } });