編輯:關於Android編程
print?<?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:orientation="vertical" >
<LinearLayout
android:id="@+id/listLinearlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</ListView>
</LinearLayout>
</LinearLayout>
<?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:orientation="vertical" >
<LinearLayout
android:id="@+id/listLinearlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</ListView>
</LinearLayout>
</LinearLayout>
?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:orientation="horizontal">
<TextView
android:id="@+id/user_name"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:paddingTop="2dip"
android:textSize="10pt"/>
<TextView
android:id="@+id/user_ip"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:paddingRight="2dip"
android:paddingTop="2dip"
android:textSize="10pt"/>
</LinearLayout>
<?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:orientation="horizontal">
<TextView
android:id="@+id/user_name"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:paddingTop="2dip"
android:textSize="10pt"/>
<TextView
android:id="@+id/user_ip"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:paddingRight="2dip"
android:paddingTop="2dip"
android:textSize="10pt"/>
</LinearLayout>
ListViewMain.java:
package com.example.wenandroid;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class ListViewMain extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
ArrayList<HashMap<String,String>> list=new ArrayList<HashMap<String,String>>();
HashMap<String,String> map1=new HashMap<String,String>();
HashMap<String,String> map2=new HashMap<String,String>();
map1.put("user_name", "張三");
map1.put("user_ip", "192.168.0.110");
map2.put("user_name", "李四");
map2.put("user_ip", "192.168.0.111");
list.add(map1);
list.add(map2);
SimpleAdapter listAdapter=new SimpleAdapter(this, list, R.layout.user, new String[]{"user_name","user_ip"}, new int[]{R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
}
protected void onListItemClick(ListView l,View v,int position,long id){
super.onListItemClick(l, v, position, id);
System.out.println("id="+id);
System.out.println("position="+position);
}
}
package com.example.wenandroid;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class ListViewMain extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
ArrayList<HashMap<String,String>> list=new ArrayList<HashMap<String,String>>();
HashMap<String,String> map1=new HashMap<String,String>();
HashMap<String,String> map2=new HashMap<String,String>();
map1.put("user_name", "張三");
map1.put("user_ip", "192.168.0.110");
map2.put("user_name", "李四");
map2.put("user_ip", "192.168.0.111");
list.add(map1);
list.add(map2);
SimpleAdapter listAdapter=new SimpleAdapter(this, list, R.layout.user, new String[]{"user_name","user_ip"}, new int[]{R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
}
protected void onListItemClick(ListView l,View v,int position,long id){
super.onListItemClick(l, v, position, id);
System.out.println("id="+id);
System.out.println("position="+position);
}
}
使用Android Studio分析內存問題
大家好!本人是即將畢業學生一枚,閒暇時間經常看大神們寫的博客學到很多東西。最近在做畢業設計的時候遇到一些問題,然後把自己的問題和解決方法總結一下,有不對的地方希望大家多多
Android抽屜導航Navigation Drawer實例解析
我們重點來研究一下Android抽屜導航 NavigationDrawer。先來感性認識一下這種效果吧:看了很多應用,覺得這種側滑的抽屜效果的菜單很好。不用切換到另一個頁
Android新手入門2016(16)--畫圖
畫圖設計到圖片的格式,有空可以看看圖片資源各種格式。了解一下圖片格式,對學習有用的。而且我面試別人的時候也很喜歡問這個問題,哈哈。先看個圖。直接看代碼吧,注釋很詳細了。a
Android開源--PullToRefresh
簡介:PullToRefresh是一款支持ListView,GridView,ViewPager,ScrollView,WebView等一切可以拖動,並實現