开发者

How to start another Activity?

hi i have bulid a r开发者_开发知识库ss reader for with help of ibm tutorial.I have created all the classes for it and i gave the following url "http://www.mahindrasatyam.com/rss/rssfeeds/news_updates.xml". which has the rss feeds. i wanted to get description of each article on click of item in list. for that the code is

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

but it was showing an error startSubActivity(itemintent,0);

and to remove error needed o implement its method which is

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

i want to load the description with the class Show description which is

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

but there is no view loaded on click of list item

can some one help me to solve this problem


There is no method startSubActivity, use startActivity or startActivityForResult instead. Have a look at the tutorial to learn how to use them.


You could try just using startActivity(itemintent) instead of startSubActivity(itemintent,0)? To my knowledge, you should be out of having to implement the startSubActivity method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜