android - Two arrays in one TextView in a ListView -


I have a question that I would be happy to answer.

I have two arrays, we say:

  string [] name = {"names names", "second name"}; String [] number = {"111 11 111", "222 22 222"};   

I have to put two ListViews in one item in my ListView. (I tried to paint it with the picture).

I f.ex. My name array in the list view with a simple

  lv.setAdapter (new array adapter & lt; string & gt; (this, R.layout.single_name, name);   

I have my.xml, single_name.xml and single_number.xml in my Layouts folder in my ListView.

Since I am new to this site, I am not allowed to add a picture, I will try to describe it here:


HEADER


(item one)

Name names

111 11 111


(item two)

Second name

222 22 222


And it will continue on the basis of the quantity of contacts.

Any help will be greatly appreciated :) Thanks

Thanks advance!

You also need to create a custom adapter and custom view to represent each row in your list. Will be.

For example an example of an analog adapter with 2 text views and an image view. As you see fit to include your header and see the image view, modify it

  package com.aquarius.customlistviewproject; Public class customistview adapter baseEditor {Private Arrayist & lt; String & gt; Album_names; Private Array List & lt; String & gt; NUM_PHOTOS; Public activity references; Public LayoutsInflet Flatter; Public customlist weaveadapter (activity reference, arreist & lt; string & gt; album_name, arrelist & lt; string & gt; num_photos) {super;); This.album_names = album_names; This.num_photos = num_photos; This.context = context; This.inflater = (Layout Inflator) context.getSystemService (References LAOUT_INFLATER_SERVICE); } Public object getItem (int position) {// TODO Auto generated method stub returns null; } Public long getItemId (int position) {// TODO auto generate method stub return 0; } Public int getCount () {// TODO auto generated method stub album_names.size (); } Public class viewer {Image Thumbnail; Textview title; Text view photo; } View public viewView (integer status, seeviewview, ViewGroup parents) {ViewHolder holder; If (convertView == faucet) {holder = new ViewHolder (); ConvertView = InfluenFlat (R.Lailout. LISTviewviewOO, blank); Holder Thumbnail = (image view) ConvertviewfindbackBiID (RID.imgivalogo); Holder.title = (TextView) ConvertViewTitle; Holder.photos = (text view) ConvertViewfWBiID (RTDTVViewscript); ConvertView.setTag (holder); } And holder = (seeholder) ConvertView .getTag (); Holder.thumbnail.setImageResource (R.drawable.imgview_drawable); Holder.title.setText (album_names.get (status)); Holder.photos.setText (num_photos.get (status)); Return Convertview; }   

}

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -