リスト ビュー コンテンツのすべてのレコードを取得したい。row.setonclicklistner を使用しましたが、最初の 3 ~ 4 項目は正常に機能しており、次の項目は null ポインター例外を示しています。私は何をすべきか?(*) を使用してその特定の行を示しました。
package com.example.tex.list;
public class tex extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_xutex);
ListView lt=(ListView)findViewById(R.id.listView1);
Databasequery db = new Databasequery(this);
db.open();
List<Propertiess>test= db.getAllcards();
lt.setAdapter(new myadatper(getApplicationContext(),R.layout.listlayoutdesign, test));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_xutex, menu);
return true;
}
public class myadatper extends ArrayAdapter<Propertiess>
{
List<Propertiess> items;
LayoutInflater mInflater ;
Context context;
int layoutResourceId;
Propertiess p;
public myadatper(Context context, int layoutResourceId,
List<Propertiess>items)
{
super(context, layoutResourceId, items);
this.layoutResourceId=layoutResourceId;
this.items = items;
this.context=context;
// TODO Auto-generated constructor stub
}
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
View row = convertView;
ViewHolder holder = new ViewHolder();
if(row==null)
{
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.listlayoutdesign, parent, false);
holder.name = (TextView) row.findViewById(R.id.TextView01);
holder.address = (TextView) row.findViewById(R.id.TextView02);
holder.designation=(TextView)row.findViewById(R.id.TextView03);
holder.contactno=(TextView)row.findViewById(R.id.textView1);
holder.Emailaddress=(TextView)row.findViewById(R.id.TextView04);
holder.TapToadd=(ImageView)row.findViewById(R.id.imageView1);
row.setTag(holder);
row.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
ListView l3t=(ListView)findViewById(R.id.listView1);
View view = l3t.getChildAt(position);
Exception Point ******************TextView t = (TextView)view.findViewById(R.id.TextView01);******************
TextView t2 = (TextView)view.findViewById(R.id.TextView02);
TextView t3=(TextView)view.findViewById(R.id.TextView03);
String data=t.getText().toString();
Toast.makeText(getApplicationContext(), data, Toast.LENGTH_SHORT).show();
}
});
}
else
{
holder=(ViewHolder)row.getTag();
}
String name=items.get(position).getCompanyname();
String contactno=items.get(position).getCompanycontactno();
String address=items.get(position).getCompanyaddress();
String designation=items.get(position).getCompanyempdesignation();
String Emailaddress=items.get(position).getCompanyemailaddress();
holder.name.setText(name);
holder.contactno.setText(contactno);
holder.designation.setText(designation);
holder.address.setText(address);
holder.Emailaddress.setText(Emailaddress);
int Datacount=items.size();
if(position==Datacount-1)
{
Toast.makeText(getApplicationContext(), Datacount+"", Toast.LENGTH_SHORT).show();
holder.TapToadd.setBackgroundResource(R.drawable.taptoadd);
}
Toast.makeText(getApplicationContext(), position+"", Toast.LENGTH_SHORT).show();
return row;
}
public class ViewHolder
{
TextView name;
TextView address;
TextView designation;
TextView contactno;
TextView Emailaddress;
ImageView TapToadd;
Object obj;
}
}
}