我创建了一个小Rss Feed应用程序。在这个应用程序中,我在listview中获取Rss,如果我们点击任何listview项,它将打开包含Rss详细描述的RssDetails.java活动。在此活动中,我已在此活动中实施了共享意图。
RssDetails.java
super.onCreate(savedInstanceState);
setContentView(R.layout.details);
TextView detailsTitle = (TextView)findViewById(R.id.detailstitle);
TextView detailsDescription = (TextView)findViewById(R.id.detailsdescription);
TextView detailsPubdate = (TextView)findViewById(R.id.detailspubdate);
TextView detailsLink = (TextView)findViewById(R.id.detailslink);
findViewById(R.id.sharebutton).setOnClickListener(this);
Bundle bundle = this.getIntent().getExtras();
detailsTitle.setText(bundle.getString("keyTitle"));
detailsDescription.setText(bundle.getString("keyDescription"));
detailsPubdate.setText(bundle.getString("keyPubdate"));
detailsLink.setText(bundle.getString("keyLink"));}
@Override
public void onClick(View v) {
if (v.getId()==R.id.button1) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Hello World");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Share via....play.google.com");
startActivity(Intent.createChooser(intent, "Share"));
}
}
现在我希望当我点击分享按钮时,Rss描述应该代替“Hello world”。这应该来自R.id.detailsdescription。
答案 0 :(得分:0)
尝试像这样添加..
@Override
public void onClick(View v) {
if (v.getId()==R.id.button1) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
//intent.putExtra(Intent.EXTRA_TEXT, "Hello World");
intent.putExtra(Intent.EXTRA_TEXT, detailsDescription.getText().toString());
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Share via....play.google.com");
startActivity(Intent.createChooser(intent, "Share"));
}
}
希望这会有所帮助..