بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
قابلیت رفتن به اکتیویتی دیگر در کلاس Adapterکه extend شده از BaseAdapter وجود داره؟
public class Adapter extends BaseAdapter implements View.OnClickListener {
private MyActivity activity;
private ArrayList data;
private static LayoutInflater inflater=null;
public Resources res;
ListKhodro tempValues=null;
public Adapter(MyActivity a, ArrayList<ListKhodro> d, Resources resLocal) {
/********** Take passed values **********/
activity = a;
data=d;
res = resLocal;
/*********** Layout inflator to call external xml layout () **********************/
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/******** What is the size of Passed Arraylist Size ************/
public int getCount() {
if(data.size()<=0)
return 1;
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
/********* Create a holder to contain inflated xml file elements ***********/
public static class ViewHolder{
public TextView text;
public TextView text2;
}
/*********** Depends upon data size called for each row , Create each ListView row ***********/
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
ViewHolder holder;
if(convertView==null){
/********** Inflate tabitem.xml file for each row ( Defined below ) ************/
vi = inflater.inflate(R.layout.listk, null);
/******** View Holder Object to contain tabitem.xml file elements ************/
holder=new ViewHolder();
holder.text=(TextView)vi.findViewById(R.id.textView);
holder.text2=(TextView)vi.findViewById(R.id.textView2);
// holder.image=(ImageView)vi.findViewById(R.id.image);
/************ Set holder with LayoutInflater ************/
vi.setTag(holder);
}
else
holder=(ViewHolder)vi.getTag();
if(data.size()<=0)
{
holder.text.setText("No Data");
}
else
{
/***** Get each Model object from Arraylist ********/
tempValues=null;
tempValues = (ListKhodro) data.get(position);
/************ Set Model values in Holder elements ***********/
holder.text.setText(tempValues.getCompanyName());
holder.text2.setText(tempValues.getUrl());
// holder.image.setImageResource(res.getIdentifier("com.example.amir.burs:drawable/"+tempValues.getImage(),null,null));
/******** Set Item Click Listner for LayoutInflater for each row ***********/
vi.setOnClickListener(new OnItemClickListener(position));
// Intent intent = new Intent(G.curentActivity,MyActivity.class);
// G.curentActivity .startActivity(intent);
// putExtra(s, text.getText().toString());
}
return vi;
}
@Override
public void onClick(View v) {
Log.v("CustomAdapter", "=====Row button clicked");
}
/********* Called when Item click in ListView ************/
private class OnItemClickListener implements View.OnClickListener {
private int mPosition;
OnItemClickListener(int position){
mPosition = position;
}
@Override
public void onClick(View arg0) {
Intent i = new Intent(G.curentActivity,MyActivity2.class);
startActivity(i);
// putExtra(s, text.getText().toString());
MyActivity sct = (MyActivity)activity;
sct.onItemClick(mPosition);
// Intent intent = new Intent(G.curentActivity,MyActivity.class);
// intent. putExtra("", tempValues.getText().toString());
// G.curentActivity.startActivity(intent);
}
private void startActivity(Intent i) {
}
}
}
0
0
ادوستان میخوام با کلیک روی یه آیتم با اطلاعات درون اون آیتم به اکتیوتی دیگه بره ولی متوقف میشه در فراخوانی وIntentهنگام رفتن به اکتیویتی دیگر (11 سال پیش)
+1
0
بخش کنترل لیست و ویدیو (( لیست ویو )) رو نگاه کن حتما به جواب میرسی (11 سال پیش)
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .