NeoFighT
یک شنبه 27 بهمن 1392, 20:05 عصر
سلام ,
یک کلاس دارم که از ArrayAdapter ارث برده و من داخلش میخوام یک Dialog رو نشون برم و تو برنامه وقتی که میخوام Dialog رو نشون بدم برنامه بسته میشه.
البته فکر کنم مشکل از سازنده Dialog م هستش.
این هم کد کلاسم هستش.
package com.example.test_graphics_1;
import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
class MyAdapter extends ArrayAdapter<String>{
Context b_Context;
String[] b_Values;
int[] b_Drawables;
Typeface tf;
public MyAdapter(Context context, int resource, String[] objects, int[] Drawables) {
super(context, resource, objects);
this.b_Context = context;
this.b_Values = objects;
this.b_Drawables = Drawables;
tf = Typeface.createFromAsset(b_Context.getAssets(),"SEGOESCB.TTF");
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) b_Context.getSystemService(Context.LAYOUT_INFLATER _SERVICE);
View V1 = inflater.inflate(R.layout.ex_listview1,parent,fals e);
TextView Tv1 = (TextView) V1.findViewById(R.id.List_txt);Tv1.setTypeface(tf) ;
ImageView Iv1 = (ImageView) V1.findViewById(R.id.List_img);
Tv1.setText(b_Values[position]);
Iv1.setImageResource(b_Drawables[position]);
/**************************این قسمت **********************************/
Iv1.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
Dialog dlg = new Dialog(b_Context);
dlg.setTitle("sallam");
dlg.show();
return false;
}
});
return V1;
}
}
یک کلاس دارم که از ArrayAdapter ارث برده و من داخلش میخوام یک Dialog رو نشون برم و تو برنامه وقتی که میخوام Dialog رو نشون بدم برنامه بسته میشه.
البته فکر کنم مشکل از سازنده Dialog م هستش.
این هم کد کلاسم هستش.
package com.example.test_graphics_1;
import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
class MyAdapter extends ArrayAdapter<String>{
Context b_Context;
String[] b_Values;
int[] b_Drawables;
Typeface tf;
public MyAdapter(Context context, int resource, String[] objects, int[] Drawables) {
super(context, resource, objects);
this.b_Context = context;
this.b_Values = objects;
this.b_Drawables = Drawables;
tf = Typeface.createFromAsset(b_Context.getAssets(),"SEGOESCB.TTF");
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) b_Context.getSystemService(Context.LAYOUT_INFLATER _SERVICE);
View V1 = inflater.inflate(R.layout.ex_listview1,parent,fals e);
TextView Tv1 = (TextView) V1.findViewById(R.id.List_txt);Tv1.setTypeface(tf) ;
ImageView Iv1 = (ImageView) V1.findViewById(R.id.List_img);
Tv1.setText(b_Values[position]);
Iv1.setImageResource(b_Drawables[position]);
/**************************این قسمت **********************************/
Iv1.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
Dialog dlg = new Dialog(b_Context);
dlg.setTitle("sallam");
dlg.show();
return false;
}
});
return V1;
}
}