Android说明设置界面布局

先上图:

 

 

哈哈 代驾和健康,加上家政 这吉祥三宝都是易盟公司的应用 请支持 。。。

 

说明设置界面是一般应用比不可少的组成,其布局一般使用圆角listview ,圆角的方法我也是从网上找的

http://blog.csdn.net/tt5267621/article/details/6987174

 

 

程序员都懒,你懂的.

 

1.先看布局 main_more.xml

[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:background="@color/white"  
  6.     android:orientation="vertical" >  
  7.   
  8.     <LinearLayout  
  9.         android:id="@+id/linearLayout1"  
  10.         android:layout_width="match_parent"  
  11.         android:layout_height="wrap_content"  
  12.         android:orientation="vertical"  
  13.         android:paddingBottom="5dp"  
  14.         android:paddingLeft="25dp"  
  15.         android:paddingTop="15dp" >  
  16.   
  17.         <TextView  
  18.             android:id="@+id/menu_1"  
  19.             android:layout_width="wrap_content"  
  20.             android:layout_height="wrap_content"  
  21.             android:text="@string/setting"  
  22.             android:textColor="@color/gray" />  
  23.     </LinearLayout>  
  24.   
  25.     <com.corner.test.CornerListView  
  26.         android:id="@+id/list1"  
  27.         android:layout_width="fill_parent"  
  28.         android:layout_height="wrap_content"  
  29.         android:layout_marginLeft="15dp"  
  30.         android:layout_marginRight="15dp"  
  31.         android:background="@drawable/shape_bg_listview"  
  32.         android:cacheColorHint="@null"/>  
  33.       
  34.      <LinearLayout  
  35.         android:id="@+id/linearLayout2"  
  36.         android:layout_width="match_parent"  
  37.         android:layout_height="wrap_content"  
  38.         android:orientation="vertical"  
  39.         android:paddingBottom="5dp"  
  40.         android:paddingLeft="25dp"  
  41.         android:paddingTop="15dp" >  
  42.   
  43.         <TextView  
  44.             android:id="@+id/menu_2"  
  45.             android:layout_width="wrap_content"  
  46.             android:layout_height="wrap_content"  
  47.             android:text="@string/setting"  
  48.             android:textColor="@color/gray" />  
  49.     </LinearLayout>  
  50.   
  51.     <com.corner.test.CornerListView  
  52.         android:id="@+id/list2"  
  53.         android:layout_width="fill_parent"  
  54.         android:layout_height="wrap_content"  
  55.         android:layout_marginLeft="15dp"  
  56.         android:layout_marginRight="15dp"  
  57.         android:background="@drawable/shape_bg_listview"  
  58.         android:cacheColorHint="@null"/>  
  59.   
  60. </LinearLayout>  


 

 

2.再看代码:

[java]  view plain copy
  1. package com.corner.test;  
  2.   
  3. import java.util.ArrayList;  
  4. import java.util.HashMap;  
  5. import java.util.List;  
  6. import java.util.Map;  
  7.   
  8. import android.app.Activity;  
  9. import android.os.Bundle;  
  10. import android.view.View;  
  11. import android.widget.AdapterView;  
  12. import android.widget.AdapterView.OnItemClickListener;  
  13. import android.widget.SimpleAdapter;  
  14.   
  15.   
  16. /*  Android实现圆角ListView示例*/  
  17.   
  18.   
  19. public class RoundCornerActivity extends Activity {  
  20.       
  21.      private CornerListView cornerListView1 = null;  
  22.      private CornerListView cornerListView2 = null;  
  23.   
  24.     ArrayList<HashMap<String, String>> map_list1 = null;  
  25.  private List<Map<String, Object>> map_list2 = null;  
  26.   
  27.     /** Called when the activity is first created. */  
  28.     @Override  
  29.     public void onCreate(Bundle savedInstanceState) {  
  30.         super.onCreate(savedInstanceState);  
  31.         setContentView(R.layout.main_more);  
  32.         cornerListView1 = (CornerListView)findViewById(R.id.list1);  
  33.         cornerListView2 = (CornerListView)findViewById(R.id.list2);  
  34.   
  35.         getDataSource1();  
  36.         getDataSource2();  
  37.         SimpleAdapter adapter1 = new SimpleAdapter(getApplicationContext(), map_list1,R.layout.simple_list_item_1,   
  38.                 new String[] { "item" },new int[] { R.id.item_title });  
  39.         cornerListView1.setAdapter(adapter1);  
  40.         cornerListView1.setOnItemClickListener(new OnItemClickListener() {  
  41.         @Override  
  42.         public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,  
  43.                 long arg3) {  
  44.             if (arg2 == 0) {  
  45.                 System.out.println("0");  
  46.             }else if(arg2 == 1){  
  47.                 System.out.println("1");  
  48.             }  
  49.             else if(arg2 == 2){  
  50.                 System.out.println("2");  
  51.             }  
  52.               
  53.         }  
  54.         });  
  55.           
  56.           
  57.         SimpleAdapter adapter2 = new SimpleAdapter(getApplicationContext(), map_list2, R.layout.simple_list_item_2,  
  58.                 new String[]{"text","img"}, new int[]{R.id.setting_list_item_text,R.id.setting_list_item_arrow});  
  59.         cornerListView2.setAdapter(adapter2);  
  60.         cornerListView2.setOnItemClickListener(new OnItemClickListener() {  
  61.             @Override  
  62.             public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,  
  63.                     long arg3) {  
  64.                 if (arg2 == 0) {  
  65.                     System.out.println("3");  
  66.                 }else if(arg2 == 1){  
  67.                     System.out.println("4");  
  68.                 }  
  69.                   
  70.                   
  71.             }  
  72.             });  
  73.     //  cornerListView2.setOnItemClickListener(new OnItemListSelectedListener());  
  74.   
  75.     }  
  76.   
  77.     public ArrayList<HashMap<String, String>> getDataSource1() {  
  78.   
  79.         map_list1 = new ArrayList<HashMap<String, String>>();  
  80.         HashMap<String, String> map1 = new HashMap<String, String>();  
  81.         HashMap<String, String> map2 = new HashMap<String, String>();  
  82.         HashMap<String, String> map3 = new HashMap<String, String>();  
  83.   
  84.         map1.put("item""设置1");  
  85.         map2.put("item""设置2");  
  86.         map3.put("item""设置3");  
  87.   
  88.         map_list1.add(map1);  
  89.         map_list1.add(map2);  
  90.         map_list1.add(map3);  
  91.   
  92.         return map_list1;  
  93.     }  
  94.       private List<Map<String, Object>>  getDataSource2() {   
  95.            map_list2 = new ArrayList<Map<String, Object>>();   
  96.         
  97.             Map<String, Object> map = new HashMap<String, Object>();   
  98.             map.put("text""代驾宝");   
  99.                     map.put("img", R.drawable.icon);   
  100.             map_list2.add(map);   
  101.         
  102.             map = new HashMap<String, Object>();   
  103.             map.put("text""健康宝");   
  104.                     map.put("img", R.drawable.icon);   
  105.             map_list2.add(map);   
  106.   
  107.             return map_list2;   
  108.         }   
  109.     }   
  110.   
  111. //  
  112. //  class OnItemListSelectedListener implements OnItemClickListener {  
  113. //  
  114. //      @Override  
  115. //      public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,  
  116. //              long arg3) {  
  117. //          if (arg2 == 0) {  
  118. //              System.out.println("0");  
  119. //          }else{  
  120. //              System.out.println("1");  
  121. //          }  
  122. //      }  
  123.       


这里面巧妙的使用了两个list完成了 整个布局,然后使用控件分别获得list的点击id ,加入监听。

 

下载地址 :http://www.kuaipan.cn/file/id_28743136620604773.htm


http://blog.csdn.net/ma969070578/article/details/7896372

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值