Используйте приведенный ниже код, чтобы сделать это
package com.app.listdnd;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class ListDnD extends Activity {
/** Called when the activity is first created. */
private ListView lvList;
private EfficientAdapter mAdapter;
private ArrayList<String> ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lvList=(ListView)findViewById(R.id.lsone);
list = new ArrayList<String>();
list.add("One");
list.add("Two");
list.add("Three");
list.add("Four");
list.add("Five");
list.add("Six");
mAdapter = new EfficientAdapter(this);
lvList.setAdapter(mAdapter);
}
private class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return list.size();
}
public Object getItem(int pos) {
return pos;
}
public long getItemId(int pos) {
return pos;
}
public View getView(final int pos, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.newsstand_listrow,
null);
convertView.setBackgroundColor(Color.WHITE);
holder = new ViewHolder();
holder.item = (TextView) convertView
.findViewById(R.id.textView1);
holder.item1 = (TextView) convertView
.findViewById(R.id.textView2);
holder.item.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("GetClick...", "TextView");
}
});
holder.item1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("GetClick...", "TextView1");
}
});
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.item.setText(list.get(pos));
return convertView;
}
class ViewHolder {
TextView item,item1;
}
}
}