肆意先生XD 2015-09-16 01:04 采纳率: 0%
浏览 2178

Android使用Switch控件会出现一串数字

JAVA代码部分

 private void initLeftMenu() {
        //侧滑菜单初始化函数,设置Adapter

        this.initTextSwitch("自动更新");
        this.initTextSwitch("多彩界面");
        this.initExpList();
        this.initExpList();

        this.leftMenuListDataAdapter1 = new SimpleAdapter(this,
                this.leftMenuDataList,
                R.layout.liststyle_text_swc,
                new String[]{"btnName","setBtn"},
                new int[]{R.id.btnName,R.id.setSwitch});
        this.leftMenuList.setAdapter(leftMenuListDataAdapter1);

//      this.leftMenuListDataAdapter2 = new SimpleAdapter();
//      this.leftMenuList.setAdapter(leftMenuListDataAdapter2);
        /** 未实现  **/
    }   
    private void initTextSwitch(String value){
        //侧滑菜单初始化函数,初始化<TextView+Switch>,被initLeftMenu()方法调用
        Map<String,String> map = new HashMap<String,String>();

        map.put("btnName",value);
        map.put("setBtn",String.valueOf(R.id.setSwitch));
        leftMenuDataList.add(map);      
    }

XML文件代码

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/btnName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="14sp"
        android:textColor="#de000000"
        android:layout_marginLeft="16dp"
         />

   <Switch
        android:id="@+id/setSwitch" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="72dp"
         />


</LinearLayout>
![图片说明](https://img-ask.csdn.net/upload/201509/16/1442365436_853667.jpg)
  • 写回答

6条回答 默认 最新

  • 肆意先生XD 2015-09-16 01:05
    关注

    图片说明

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?