如何在Intent.ACTION_VIEW之后显示数据?

时间:2014-02-15 15:18:09

标签: android android-layout android-intent android-search

我正在创建搜索我的应用程序,我需要做的最后一件事就是在用户点击搜索建议时“提取”数据。我已设置Intent.ACTION_VIEW并按intent.getData()获取数据;在我可搜索的活动中。但是我现在应该怎么做才能在数据中查看TextViews和ImageView“打包”的对象?我没有这方面的经验,所以你能给我任何建议吗?

非常感谢

我的代码示例:

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?

}

1 个答案:

答案 0 :(得分:0)

只需将它们添加到您活动的任何布局中,它们都会显示在其中。

How to Programmatically Add Views to Views

例如,您有一个ID为mylayout的LinearLayout。

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

或者,您可以处理视图并仅使用来自它们的数据 - 来自TextView的文本,可从ImageView中绘制等等。