<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<ListView
android:id="@+id/lv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#DB7093"
android:textSize="30sp"
/>
<TextView
android:id="@+id/text"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</TextView>
public class Main2Activity extends AppCompatActivity {
public String[] names = new String[]{"C语言", "C++", "Java","Python","C#"};
public String[] says = new String[]{"从入门到入土", "面向对象", "就业必需","后起之秀",".Net"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
ArrayList<Map<String,Object>> mylist = new ArrayList<Map<String,Object>>();
for(int i=0;i<names.length;i++)
{
Map<String,Object> showitem = new HashMap<String,Object>();
showitem.put("name", names[i]);
showitem.put("text", says[i]);
mylist.add(showitem);
}
SimpleAdapter myAdapter = new SimpleAdapter(this,
mylist,
R.layout.listitems,
new String[] {"name", "text"},
new int[] {R.id.name,R.id.text});
ListView listView = (ListView) findViewById(R.id.lv);
listView.setAdapter(myAdapter);
}
}