如何开始另一项活动?

时间:2011-05-25 13:39:40

标签: android button

喜     我已经在ibm教程的帮助下建立了一个rss阅读器。我已经为它创建了所有类,我给了以下网址“http://www.mahindrasatyam.com/rss/rssfeeds/news_updates.xml”。 哪个有rss feed。 我希望在列表中单击项目时获得每篇文章的描述。 对于那个代码 是

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

但显示错误 startSubActivity(itemintent,0);

并删除实现其方法

所需的错误
private void startSubActivity(Intent itemintent, int i) {
    // TODO Auto-generated method stub  
}

我想加载类别显示描述

的描述
public class ShowDescription extends Activity 
{
    public void onCreate(Bundle icicle) 
    {
        super.onCreate(icicle);
        setContentView(R.layout.showdescription);

        String theStory = null;


        Intent startingIntent = getIntent();

        if (startingIntent != null)
        {
            Bundle b = startingIntent.getBundleExtra("android.intent.extra.INTENT");
            if (b == null)
            {
                theStory = "bad bundle?";
            }
            else
            {
                theStory = b.getString("title") + "\n\n" + b.getString("pubdate") + "\n\n" + b.getString("description").replace('\n',' ') + "\n\nMore information:\n" + b.getString("link");
            }
        }
        else
        {
            theStory = "Information Not Found.";

        }

        TextView db= (TextView) findViewById(R.id.storybox);
        db.setText(theStory);

        Button backbutton = (Button) findViewById(R.id.back);

        backbutton.setOnClickListener(new Button.OnClickListener() 
        {
            public void onClick(View v) 
            {
                finish();
            }
        });        
    }
}

但点击列表项

时没有加载任何视图

可以帮助我解决这个问题吗

2 个答案:

答案 0 :(得分:2)

您可以尝试使用startActivity(itemintent)代替startSubActivity(itemintent,0)吗?据我所知,您应该不必实现startSubActivity方法。

答案 1 :(得分:2)

没有方法startSubActivity,而是使用startActivitystartActivityForResult。看看at the tutorial,了解如何使用它们。

相关问题