0

I'm creating search for my app and one of the last things I need to do is to "extract" the data when the user clicks on search-suggestion. Ive set Intent.ACTION_VIEW and got data by intent.getData(); in my searchable activity. But what should i do now to view the objects such as TextViews and ImageView "packaged" in the data? I have no big experience with this, so could you give me any advice please?

Thanks a lot

My example of code:

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?

}
marson
  • 913
  • 10
  • 32

1 Answers1

0

Just add them to any layout in your activity, and they will be shown in it.

How to Programmatically Add Views to Views

For expample, you have a LinearLayout with id mylayout.

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

Alternatively, you can dispose of views and use only data from them - text from TextView, drawable from ImageView and etc.

Community
  • 1
  • 1
weaknespase
  • 1,014
  • 8
  • 15