I'm applying a simple "search" Each search includes a list of things I show the title of each search I want to show a list of available searches with buttons.
I have every search and its glasses are in DB. After some tutorials like they use an array adapter to show the list, but it requires "textview resource id" in the layout. I do not know that I want to take the title of every search (which I get from DB) in the layout and put it on the button, because I never use text ideas.
For clarity, here is the code of activity where I retrieve data from DB.
Public Class InProgress ListActivity {private questspecdao datasource; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.main); Data source = new questionspeccardo (this); Datasource.open (); & Lt; Questspec & gt; Value = datasource.get all quoices (); ArrayAdapter & LT; Questspec & gt; Adapter = new Arrayheader & lt; Questspec & gt; (This, R. L. Quistro, Mann); SetListAdapter (adapter); } @ Override Protected Zero on Reorganization () {datasource.open (); Super.onResume (); } @ Override Protected Zero at Pause () {datasource.close (); Super.onPause (); }} Thanks in advance!
You're creating wrong optimization of the array adapter.
According to Android official, an array adapter, "By default this class expects that the provided resource ID refers to a text view" This means that it only supports one TextView so that you can apply it to:
ArrayAdapter array adapter = new array adapter (this, android.R.layout. Simple_list_item_1, array / ** your data string goes here.] /); / ** sets the adapter in your declared list view. * / YoutlistView.setAdapter (array adapter); If you want a customized inventory item, you must create your own adapter:
Public class MyArrayAdapter ArrayAdapter and lt; String & gt; {@ Override Public View getView (see integer status, seeviewview, ViewGroup parents) {layoutInfleter Inflator = (layout inferrer) reference .getSystemService (reference. LAOUT_INFLATER_SERVICE); / ** Enhancing an XML layout in the view * / view item view = inflater.inflate (R. layout.overout, guardian, wrong); / ** Declare all your items on the last defined line layout xml file * / text view text view = (text view) item view FindVibIID (Rd.txtview); ImageView imageView = (ImageView) itemView .findViewById (RID.Con); / ** Set some values in declared item views. * / TextView.setText (value [position]); If (value [condition] is included ("XXXXXXX")) {imageView.setImageResource (R.drawable.x); } And {imageView.setImageResource (R.drawable.y); } View return items; }} Let me know that it helps you :)
Comments
Post a Comment