标签:lisspan idtransmarks imagspan idtransmark launcspan idtransmar ospan idtransmarkspa objspan idtransmarks
package com.jia.baseadapter; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; public class MainActivity extends Activity { private ListView myList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myList = (ListView) findViewById(R.id.myList); BaseAdapter adapter = new BaseAdapter() { @Override public View getView(int position, View convertView, ViewGroup parent) { // 創建一个LinearLayout,并向其中添加两个组件 LinearLayout line = new LinearLayout(MainActivity.this); line.setOrientation(0); ImageView imageView = new ImageView(MainActivity.this); imageView.setImageResource(R.drawable.ic_launcher); TextView textView = new TextView(MainActivity.this); textView.setText("第" + (position + 1) + "个列表项"); textView.setTextSize(30); textView.setTextColor(Color.GREEN); line.addView(imageView); line.addView(textView); // 返回LinearLayout实例 return line; } @Override public long getItemId(int position) { // 重写该方法,该方法的返回值将作为列表项的ID return position; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public int getCount() { // 指定一共包含8000个选项 return 8000; } }; myList.setAdapter(adapter); } }
标签:lisspan idtransmarks imagspan idtransmark launcspan idtransmar ospan idtransmarkspa objspan idtransmarks
原文地址:http://blog.csdn.net/fang323619/article/details/43702199