Android ListView with TextView and Spinner -
Initial question here I wonder if someone can tell me in the right direction. I need a list view of 'accounts' where each item will include a text view and a spinner to choose from a predetermined amount, so each item will:
________________________. Text view ------ spinner | | ________________________ | I have so far:
activity_topup.xml is the main XML for this activity And then my Java file TopUpActivity.java String [] listAccounts = { "Acc1", "Acc2" , "ExC3"}; AccountListAdapter = New Arrayheader & lt; String & gt; (This, R.Let.LilVestu_Item_Counts, RID.Account_L_L_YSTEV, LISTEX); ListView = (ListView) findViewById (R.id.topup_accounts_listview); ListView.setAdapter (accountListAdapter); listview_item_accounts.xml contains the contents of each item (a text viewer and spinner) & lt; TextView android: id = "" @ + id / accounts_list_tv Android: layout_width = "150dp" Android: Layout_height = "Wrap_content" Android: layout_alignParentLeft = "true" Android: layout_toLeftOf = "@ + id / accounts_list_amt_spinner" android: background = "@ Drawable / list_item_selector_grey "style =" @ style / list text "/> & Lt; Spinner android: id = "@ id / Accounts_list_amt_spinner" Android: layout_width = "96dp" Android: Layout_height = "Wrap_content" Android: layout_alignParentRight = "true" android: prompt = "@ string / Topup_amt_prompt" android: background = "@ drawable / List_it_c_ct / blue "style =" @ style / list text "/> Am I on the right track ?! The result is correct but how can I populate a spinner, it is not able to understand that I can use the method I can use by using this method. I also added in an attempt to populate the spinners Java file, but spinner remain empty:
// ListView Items Increase layout Infletr Inflaattr = (Leautinflatr) getSystemService (reference. LAOUT_INFLATER_SERVICE ); See vi = inflater.inflate (R.layout.listview_item_accounts, blank); // spinner amt = (spinner) vi.findViewById (R.id.accounts_list_amt_spinner); // By setting this adapter ArrayAdapter & lt; Charsequence & gt; Add value for the spinner. Adapter = Arreadaptrksentform resource (it Arkratrktopap_amts, Android. R. Lett. Simple_search Spinr_aitem); Adapter.setDropDownViewResource (android.R.layout.simple_spinner_dropdown_item); Amt.setAdapter (adapter); (spinners have a blue background):
And when I click on a spinners they are empty,
You have to meet your original ideas in his parents. For example, in your adapter's getView , you spinner sum = (spinner) item.findViewById (Free / Group> GroupView) In the form (with listview_item_accounts.xml) your item name is with "item", then you have to put a spinner in it id.accounts_list_amt_spinner; If you use
spinner AMT = (spinner), then use VVIBID (RIDXX_List_Ammat_pinner); You have tried to find a view that this id is equal to "R.id.accounts_list_lamt_spinner" in the content view, not in every item.
Comments
Post a Comment