2014-02-15 47 views
0

我正在为我的应用程序创建搜索,我需要做的最后一件事情之一是在用户单击搜索建议时“提取”数据。我设置了Intent.ACTION_VIEW并通过intent.getData()得到了数据;在我的搜索活动。但是,我现在应该怎么做才能查看数据中的“打包”TextView和ImageView等对象?我对此没有太大的经验,所以你能给我一些建议吗?如何在Intent.ACTION_VIEW之后显示数据?

非常感谢

我的代码示例:

if (Intent.ACTION_VIEW.equals(intent.getAction())) { 
      setContentView(R.layout.activity_more); 
      intent.getData(); 
      final ProgressBar progress = (ProgressBar) findViewById(R.id.more_progress); 
      progress.setVisibility(View.VISIBLE); 
      TextView about = (TextView)findViewById(R.id.more_about); 
      TextView animal = (TextView)findViewById(R.id.more_animal); 
      final ImageView imgUrl = (ImageView)findViewById(R.id.more_imgUrl); 

//now do i need to set Text etc., but how? 

} 

回答

0

只需将它们添加到任何布局在您的活动,他们将在它显示出来。

How to Programmatically Add Views to Views

对于expample,你有id为mylayout一个LinearLayout中。

LinearLayout layout = (LinearLayout) findViewById("mylayout"); 
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
layout.addView(myView, lp); 

或者,你可以配置的视图,并使用从他们唯一的数据 - 从ImageView的TextView的,从文字,绘制等

相关问题