بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
اجرای Dialog در کلاسی که از اکتیویتی Extend نشده ؟
سلام من توی پروژه feed reader میخوام هر وقت روی هر خبری از لیست ویو کلیک شد یه progress dialog باز بشه به عنوان لودیگ و بقیه کارها که اونها اوکی هست.
فقط مشکل اینه که وقتی با کد زیر میخوام دیالوگ رو نشون بدم از من یک context میخاد که چون کلاسم از ArrayAdapter<RssParser.Item> اکستند شده نمیتونم بهش دستری داشته باشم.
public void fill(final ArrayAdapter<RssParser.Item> adapter, final RssParser.Item item, final int position)
{
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
ActivityStartup.handler.post(new Runnable() {
@Override
public void run() {
ActivityStartup.dismissLoadingDialog();
txtTitle.setText(item.title);
txtDate.setText(item.pubDate);
txt_time.setText(item.time);
txtDescription.setText(item.description);
layoutRoot.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showLoadingDialog();//اینجا میخوام دیالوگ نشون داده بشه
G.SelectedApplication = item;
Intent intent = new Intent(G.context, Adapter_Description.class)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("INPUT", item.link + "");
intent.putExtra("INPUT_DESC", item.description + "");
G.context.startActivity(intent);
}
});
}
});
}
});
thread.start();
برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال
Spirit
11 سال پیش
+1
0
شما Activity رو پاس میدی به Adpater و اونجا میتونی بهش دسترسی داشته باشی (بر اساس آموزش ListView) :
این قسمت مربوط به Adapter :
public class AdapterNote extends ArrayAdapter<StructNote> {
private Activity activity; // میتونی بدی به دیالوگ
public AdapterNote(ArrayList<StructNote> array , Activity activity) {
super(G.context, R.layout.adapter_notes, array);
this.activity = activity;
}
.
.
.
.
.
.
}
و در Activity :
adapter = new AdapterNote(G.notes , ActivityMain.this);
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .
