Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 數組數據綁定到listview

android 數組數據綁定到listview

編輯:關於Android編程

package com.zxl;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
    /** Called when the activity is first created. */
    String[] presidentsStrings={
    	"h",
    	"o",
    	"fd",
    	"fe",
    	"t",
    	"h",
    	"hr",
    	"fa"
    };
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,presidentsStrings));
    }
	public void onListItemClick(
			ListView parent,View v,int position,long id){
		Toast.makeText(this,"item is "+presidentsStrings[position],Toast.LENGTH_LONG).show();
	}
	
}

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved