Android ListView复杂多功能详解
2012-09-18 09:28:02 来源:WEB开发网核心提示::layout_marginLeft="10dp" android:textSize="16sp" android:layout_weight="1" android:textStyle="bold"
:layout_marginLeft="10dp"
android:textSize="16sp"
android:layout_weight="1"
android:textStyle="bold" />
<ImageView
android:id="@+id/item_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/item_right1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
------------------------------------------.Main
package com.example.tezt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends
ListActivity {
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Map<String, Object>> datas = getDatas();
ImageAdapter adapter = new ImageAdapter(
this, datas);
this.getListView().setAdapter(
adapter);
}
private List<Map<String, Object>> getDatas() {
// TODO Auto-generated method stub
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
String[] items = this
.getResources()
.getStringArray(
R.array.menu);
android:textSize="16sp"
android:layout_weight="1"
android:textStyle="bold" />
<ImageView
android:id="@+id/item_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/item_right1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
------------------------------------------.Main
package com.example.tezt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends
ListActivity {
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Map<String, Object>> datas = getDatas();
ImageAdapter adapter = new ImageAdapter(
this, datas);
this.getListView().setAdapter(
adapter);
}
private List<Map<String, Object>> getDatas() {
// TODO Auto-generated method stub
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
String[] items = this
.getResources()
.getStringArray(
R.array.menu);
更多精彩
赞助商链接