Monday, April 7, 2014

SimpleAdapter adds two elements do not show how the content? Great God seeking help


  
android: orientation = "horizontal"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">

<-! Define a List ->
android: id = "@ + id / mylist"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent" />
<-! ImageView defined as part List ->
android: id = "@ + id / header"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: paddingLeft = "2dp" />
<-! TextView defined as part List ->
android: id = "@ + id / name"
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: textSize = "16dp"
android: gravity = "center_vertical"
android: paddingLeft = "10dp" />


 public class SimpleAdapterActivity extends Activity {

private String [] names = new String [] {
"Zhao", "money two", "three Sun", "John Doe", "Friday", "Wu six", "Zheng seven", "bastard"
};
private int [] imageIds = new int [] {
R.drawable.number_glod_img_2,
R.drawable.number_glod_img_3,
R.drawable.number_glod_img_4,
R.drawable.number_glod_img_5,
R.drawable.number_glod_img_6,
R.drawable.number_glod_img_7,
R.drawable.number_glod_img_8,
R.drawable.number_glod_img_9,
};
@ Override
protected void onCreate (Bundle savedInstanceState) {
/ / TODO Auto-generated method stub
super.onCreate (savedInstanceState);
setContentView (R.layout.simpleadapter_listview_main);
/ / Create a List collection whose elements are Map
List > listItems = new ArrayList > ();

for (int i = 0; i Map list = new HashMap ();

list.put ("header", imageIds [i]);
list.put ("personName", names [i]);

listItems.add (list);
}
/ / Create a SimpleAdapter
SimpleAdapter simpleAdapter = new SimpleAdapter (this,
(List >) listItems,
R.layout.simpleadapter_listview_main,
new String [] {"header", "personName"},
new int [] {R.id.header, R.id.name});

ListView listView = (ListView) findViewById (R.id.mylist);
/ / Set the ListView Adapter
listView.setAdapter (simpleAdapter);
}
}

No display after running, this is my operating results
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
setContentView (R.layout.simpleadapter_listview_main); delete this sentence does not put the final
Change setContentView (listView);
Reply:
I'm really afraid of you, you did not want to say, but I really could not stand up, so you do not have eyes novice learning process never progress,
SimpleAdapter simpleAdapter = new SimpleAdapter (this, (List >) listItems, Will List >) listItems What does that mean, you write a program that is so boring thing? Plus it is what you meant? You do not understand, it is not removed Well? Why must superfluous. Upstairs there is anger in the ...... more peculiar, do not you see it nonsense, he was wrong and setContentView program have anything to do,
Reply:
Hurry add my QQ trumpet 1503382384 I want Masi you, I can not see most people scrawl program, I want to call you soon add me to see I'm not a good call you
Reply:
I am grateful, but with the way you still ah, @ yming002 Brother, you do not scold me, I really am a novice, what will not, ah, want to find a program to practice your hand, and slowly started, but with a Many methods are not OK, ah, still no results, I really do not know how to put this program get out
Reply:
item have its own layout ah, SimpleAdapter simpleAdapter = new SimpleAdapter (this,
(List >) listItems,
R.layout.simpleadapter_listview_main,
new String [] {"header", "personName"},
new int [] {R.id.header, R.id.name}); layout where the layout to use their own definitions, as well as, imageview and textview not written in the main layout inside is written in this item layout in of
Reply:
Finally resolved, thank you
Reply:
How to solve ah
Reply:
5th floor there are two answers to this Activity Activity layout layout one layout to another is a list of the
SimpleAdapter simpleAdapter = new SimpleAdapter (this,
(List >) listItems,
R.layout.simpleadapter_listview_main, (Here is the list of layout)
new String [] {"header", "personName"},
new int [] {R.id.header, R.id.name});

No comments:

Post a Comment