Note that there are some explanatory texts on larger screens.

plurals
  1. POCan an ArrayAdapter used to fill a ListView be reused for a LinearLayout?
    text
    copied!<p>Happy Thanksgiving y'all!</p> <p>So my Android app is using a custom ArrayAdapter class to populate a ListView page dynamically with a custom object class. Would it be possible to use this same ArrayAdapter to populate fields (TextView, ImageViews) on a LinearLayout page?</p> <p>Basically, so my ListView page is: Item 1, Item 2, Item 3, etc...</p> <p>And each Item 1, 2, 3, etc when clicked will have it's own individual page.</p> <p>When I click on any Item #, I would want to use the ArrayAdapter to send the same info that shows on the ListView page for that item to show on the LinearLayout page. Is this possible? Or would I have to create another adapter for that individual page and pass in the same object holding the info?</p> <p>Sorry if this is a stupid question, I am still a noobie at Android programming.</p> <p>Also, if any of you have any tutorial pages you can point me in the right direction that would be very helpful! Thank you!</p> <p><strong>Fragment Code</strong></p> <pre><code>public class DealsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_show_deals, container, false); ListView listView = (ListView)view.findViewById(R.id.dealsListView); // Sample set of data passed to adapter for testing purposes Deal all_deal_data[] = new Deal[] { new Deal("Deal 1", R.drawable.test_image, 389, 700, 750, 500), new Deal("Deal 2", R.drawable.test_image, 20, 80, 1800, 1500), new Deal("Deal 3", R.drawable.test_image, 1932, 2000, 75, 60), new Deal("Deal 4", R.drawable.test_image, 198, 450, 450, 350), new Deal("Deal 5", R.drawable.test_image, 60, 70, 1500, 1100) }; // Sets up adapter to pass data into XML DealAdapter adapter = new DealAdapter(getActivity(), R.layout.listview_item_row, all_deal_data); // TO ADD HEADER ROW BACK IN // View header = (View)inflater.inflate(R.layout.listview_header_row, null); // LV.addHeaderView(header); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Intent intent = new Intent(getActivity(), DealPage.class); startActivity(intent); } }); return view; } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload