1. 程式人生 > >Android說明設定介面佈局

Android說明設定介面佈局

先上圖:

哈哈 代駕和健康,加上家政 這吉祥三寶都是易盟公司的應用 請支援 。。。

說明設定介面是一般應用比不可少的組成,其佈局一般使用圓角listview ,圓角的方法我也是從網上找的

程式設計師都懶,你懂的.

1.先看佈局 main_more.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="5dp"
        android:paddingLeft="25dp"
        android:paddingTop="15dp" >

        <TextView
            android:id="@+id/menu_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/setting"
            android:textColor="@color/gray" />
    </LinearLayout>

    <com.corner.test.CornerListView
        android:id="@+id/list1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="@drawable/shape_bg_listview"
        android:cacheColorHint="@null"/>
    
     <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="5dp"
        android:paddingLeft="25dp"
        android:paddingTop="15dp" >

        <TextView
            android:id="@+id/menu_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/setting"
            android:textColor="@color/gray" />
    </LinearLayout>

    <com.corner.test.CornerListView
        android:id="@+id/list2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="@drawable/shape_bg_listview"
        android:cacheColorHint="@null"/>

</LinearLayout>

2.再看程式碼:

package com.corner.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.SimpleAdapter;


/*  Android實現圓角ListView示例*/


public class RoundCornerActivity extends Activity {
	
	 private CornerListView cornerListView1 = null;
	 private CornerListView cornerListView2 = null;

	ArrayList<HashMap<String, String>> map_list1 = null;
 private List<Map<String, Object>> map_list2 = null;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_more);
		cornerListView1 = (CornerListView)findViewById(R.id.list1);
		cornerListView2 = (CornerListView)findViewById(R.id.list2);

		getDataSource1();
		getDataSource2();
		SimpleAdapter adapter1 = new SimpleAdapter(getApplicationContext(), map_list1,R.layout.simple_list_item_1, 
				new String[] { "item" },new int[] { R.id.item_title });
		cornerListView1.setAdapter(adapter1);
		cornerListView1.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			if (arg2 == 0) {
				System.out.println("0");
			}else if(arg2 == 1){
				System.out.println("1");
			}
			else if(arg2 == 2){
				System.out.println("2");
			}
			
		}
		});
		
        
        SimpleAdapter adapter2 = new SimpleAdapter(getApplicationContext(), map_list2, R.layout.simple_list_item_2,
        		new String[]{"text","img"}, new int[]{R.id.setting_list_item_text,R.id.setting_list_item_arrow});
        cornerListView2.setAdapter(adapter2);
        cornerListView2.setOnItemClickListener(new OnItemClickListener() {
    		@Override
    		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
    				long arg3) {
    			if (arg2 == 0) {
    				System.out.println("3");
    			}else if(arg2 == 1){
    				System.out.println("4");
    			}
    			
    			
    		}
    		});
	//	cornerListView2.setOnItemClickListener(new OnItemListSelectedListener());

	}

	public ArrayList<HashMap<String, String>> getDataSource1() {

		map_list1 = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map1 = new HashMap<String, String>();
		HashMap<String, String> map2 = new HashMap<String, String>();
		HashMap<String, String> map3 = new HashMap<String, String>();

		map1.put("item", "設定1");
		map2.put("item", "設定2");
		map3.put("item", "設定3");

		map_list1.add(map1);
		map_list1.add(map2);
		map_list1.add(map3);

		return map_list1;
	}
	  private List<Map<String, Object>>  getDataSource2() { 
	       map_list2 = new ArrayList<Map<String, Object>>(); 
	  
	        Map<String, Object> map = new HashMap<String, Object>(); 
	        map.put("text", "代駕寶"); 
	    	        map.put("img", R.drawable.icon); 
	        map_list2.add(map); 
	  
	        map = new HashMap<String, Object>(); 
	        map.put("text", "健康寶"); 
	    	        map.put("img", R.drawable.icon); 
	        map_list2.add(map); 

	        return map_list2; 
	    } 
	} 

//
//	class OnItemListSelectedListener implements OnItemClickListener {
//
//		@Override
//		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
//				long arg3) {
//			if (arg2 == 0) {
//				System.out.println("0");
//			}else{
//				System.out.println("1");
//			}
//		}
	


這裡面巧妙的使用了兩個list完成了 整個佈局,然後使用控制元件分別獲得list的點選id ,加入監聽。

相關推薦

Android說明設定介面佈局

先上圖: 哈哈 代駕和健康,加上家政 這吉祥三寶都是易盟公司的應用 請支援 。。。 說明設定介面是一般應用比不可少的組成,其佈局一般使用圓角listview ,圓角的方法我也是從網上找的 程式設計師都懶,你懂的. 1.先看佈局 main_more.xm

AndroidAndroid-鍵盤遮蓋介面佈局問題

一、在解決Android輸入法鍵盤彈出問題是,我們先來了解幾個常用的api <activity android:windowSoftInputMode= "A"'> A=“stateUnspecified” 依賴系統或者主題去設定鍵盤彈出 A=

Android開發:介面佈局的基本使用

問題提出 在android開發中,一個好的程式,除了強大的功能以外,還要有一個能吸引別人眼球的介面。縱觀當下流行的諸多Android軟體,那些絢麗多彩,美輪美奐的程式介面與手觸屏完美結合,給我們帶來了不一般的使用者體驗,也把我們帶進了夢幻般的Android世界。

ConstraintLayout優化佈局-上-Android視覺化介面佈局

轉載自:http://blog.csdn.net/seu_calvin/article/details/55522706      感謝博主SEU_Calvin的整理和詳細介紹。 0. 前言 ConstraintLayout是中主要的新增功能之一,我們都知道在傳統

Android Fragment碎片-片段(不同佈局,仿手機設定介面

package com.example.android_11; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends App

Android Launcher分析和修改2——Icon修改、介面佈局調整、桌布設定

<!-- Workspace cell size --> <dimen name="workspace_cell_width_land">88dp</dimen> <dimen name="workspace_cell_width_port">

Android跳轉設定介面以及報錯的處理

       因為SDK版本不同,所以有時我們在應該程式想要跳轉到設定輔助頁面,會報異常,程式會掛掉。有時會報找不到相關類,包是沒問題的。後來在google查看了各個資料,各版本的sdk提供是有差異的,分別3.0以下和3.0以上。

Android動態設定佈局寬高

例如設定一個圖片寬高 關鍵程式碼: //取控制元件當前的佈局引數 LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imageView.getLayoutParams(); //設定寬度值 params.wi

Android 動態設定佈局屬性

Android在XML檔案中寫佈局很方便, 但有時候不夠靈活, 有時候我們需要動態新增View或者ViewGroup. 點選動態新增TextView: private LinearLayout mLinearLayout; private in

Android--介面佈局

前言 Android中的介面開發中常用到的五種佈局方式: 1,LinearLayout(線性佈局)。在xml文字中啥位置寫它就按順序一個個接在後面。 2,FrameLayout(框架佈局),便於讓控制元件一個個疊上去 3,TableLayout(表格佈局),顧名思義就像表格那樣一個表

Android學習之介面設定

最近實訓正在學習Android程式編寫,以下內容主要是自己在課堂上所學東西的總結。 本文采用eclipse編寫Android應用程式,今天從最基礎的介面設計開始記錄。 1.新建檔案 在選單欄找到File->new->Android Application Project,如下圖所示

[Android 效能優化系列]佈局篇之減少你的介面層級

轉載請標明出處(http://blog.csdn.net/kifile),再次感謝 在接下來的一段時間裡,我會每天翻譯一部分關於效能提升的Android官方文件給大家 效能優化之佈局篇: 題外話: 複雜的佈局,既會提高我們的設計難度,也會降低我們的程式碼效

Android控制介面佈局的兩種方式

概念一:View Android所有UI元件都繼承自View類,View類是一個抽象類,不能直接建立View類的物件(即不能直接例項化),通常是例項化View類的子類,即具體的UI元件或佈局管理器。 View類還有一個重要的子類:ViewGroup,ViewGroup也是一個抽象類,所以也不能直接例項化

android 動態設定控制元件的高度,使用對應佈局中的dp值

1. 獲取你要進行改變的控制元件的佈局 LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) myView.getLayoutParams(); 2.設定佈局的高度   後面的引數就是對應

Android Studio設定程式碼字型大小與介面字型樣式

前言 使用android studio第一步肯定就是設定字型大小了,廢話不多說,直接上教程: 初始介面: 更改後介面: 目錄 更改程式碼字型大小 更改介面字型大小及樣

Android 6.0動態許可權及跳轉GPS設定介面

public class CheckPermissionsActivity extends Activity implements ActivityCompat.OnRequestPermissionsResultCallback { /** * 需要進行檢測的許可權陣列 */ prote

android 跳轉到應用通知設定介面

4.4以下並沒有提過從app跳轉到應用通知設定頁面的Action,可考慮跳轉到應用詳情頁面,下面是直接跳轉到應用通知設定的程式碼: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPO

Android 跳轉許可權設定介面的終極適配(適配各大定製 ROM)

▲ 前言: 當我們的使用者使用App時不小心拒絕了某項必要許可權,而導致無法正常使用。這時候希望重新去開啟該許可權,那麼問題來了,Android廠家定製的room五花八門,很多時候卻發現找不到許可權管理的入口。為了解決這一問題,如果我們應用中直接提供許可權管理入口給

Android 自定義 Dialog 佈局設定高度 wrap_content 無效

以前的一個 Dialog 的自定義佈局的根佈局的寬度是寫死的,高度是 wrap_content 的。後來加了幾行內容後,發現內容總是顯示不全,高度沒有自適應,似乎變成了一個固定高度。根佈局是一個垂直的 LinearLayout,之前的內容比較少,所以沒發現問題。這期在底部添加

Android-計算器的實現(介面佈局,計算邏輯處理)

    原始碼下載    閒來無事,用android做一個計算器玩玩,想著做一個私密空間,表面是計算器,按下原先設定的算式後可以跳轉到私密介面,當想想有些費事,以後若還有閒散時間,再來實現。    介面是這樣的,採用了GridLayout佈局,很容易實現。程式碼如下<?