<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <ListView        android:id="@+id/listView2"        android:layout_width="match_parent"        android:layout_height="wrap_content" >    </ListView>    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="TextView" />    <TextView        android:id="@+id/textView2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="TextView" /></LinearLayout>

public class MainActivity extends Activity {    private int status = 0;    private String[] books2 = new String[] { "乖,摸摸头", "从你的全世界路过", "杜拉拉升职记" };    private String[] author = new String[] { "大冰","张嘉佳","xxx"};    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        this.setContentView(R.layout.activity_main);        ListView listView = (ListView) findViewById(R.id.listView2);        int[] to = new int[]{R.id.textView1,R.id.textView2};        List<Map<String,Object>> data = new ArrayList<Map<String, Object>>();        for(int i=0;i<books2.length;i++){            Map<String,Object> newMap = new HashMap<String, Object>();            newMap.put("author", this.author[i]);            newMap.put("book", this.books2[i]);            data.add(newMap);        }        SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.activity_main, new String[]{"book","author"}, to);        listView.setAdapter(adapter);    }    @Override    public boolean onCreateOptionsMenu(Menu menu) {        getMenuInflater().inflate(R.menu.main, menu);        return true;    }}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 通过一个简单的案例看懂量子计算机
  2. 谷歌官宣:全面超越人类的最强NLP预训练模
  3. 坚果云和亿方云哪个好用?
  4. 坚果云和亿方云哪个更适合学校?
  5. RocketMQ 初探
  6. 看透 Spring MVC 源代码分析与实践 ——
  7. SpringBoot RabbitMQ 整合进阶版
  8. 看透 Spring MVC 源代码分析与实践 ——
  9. SpringBoot ActiveMQ 整合使用
  10. 死磕这50道MySQL面试题,阿里面试官直呼内