package com.in2em.hotel;
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
@SuppressLint("ParserError")
在列表视图中显示两个数组列表的活动
public class OrderActivity extends ListActivity {
ArrayList<String> data,rate;
OrderAdapter orderAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.order);
Bundle extras = getIntent().getExtras();
data = extras.getStringArrayList("list");
rate = extras.getStringArrayList("rate");
for(String str : data) {
Log.d("data", str);
}
for(String str1 : rate) {
Log.d("data", str1);
}
数据和速率是两个数组列表
String[] captionArray = (String[]) data.toArray(
new String[data.size()]);
String[] rateArray = (String[]) rate.toArray(
new String[rate.size()]);
R.layout.order_list,R.id.itemname, captionArray));
如何在 listview 中设置两个数组列表?我只能设置一个数组列表?
orderAdapter = new OrderAdapter(
OrderActivity.this, R.layout.order_list,
captionArray);
设置列表适配器
setListAdapter(orderAdapter);
return ;
}
自定义列表适配器
private class OrderAdapter extends BaseAdapter {
String[] items;
public OrderAdapter(Context context, int textViewResourceId,
String[] items) {
this.items = items;
}
返回视图
public View getView(final int POSITION, View convertView,
ViewGroup parent) {
TextView tvNumber,tvName,tvRate;
EditText etQty,etRemarks;
View view = convertView;
膨胀
if (view == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.order_list, null);
}
tvName = (TextView) findViewById(R.id.itemname);
tvRate = (TextView) findViewById(R.id.itemrate);
tvName.setText(data.get(POSITION));
tvRate.setText(rate.get(POSITION));
return view;
}
public int getCount() {
// TODO Auto-generated method stub
return items.length;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
}
}