0

アプリの検索を作成していますが、最後に行う必要があることの 1 つは、ユーザーが検索候補をクリックしたときにデータを「抽出」することです。によってデータを設定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?

}
4

1 に答える 1

0

それらをアクティビティの任意のレイアウトに追加するだけで、その中に表示されます。

プログラムでビューをビューに追加する方法

たとえば、 id を持つ LinearLayout がありますmylayout

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

または、ビューを破棄して、それらのデータ (TextView のテキスト、ImageView のドローアブルなど) のみを使用することもできます。

于 2014-02-15T15:35:58.087 に答える