即時嘗試在GridView項目上創建一個對話框單擊一個擴展片段的類我已經完成了一些帖子,但那是描述該類的擴展FragmentDialog我不明白如何在下面實現是我的課在擴展片段的類中顯示DialogBox
public class Favourite extends Fragment {
GridView gv;
Context context;
SQLiteDatabase db;
String[] title_array,id_array;
Bitmap[] img_array;
Cursor c,c1;
@Nullable
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
db = getActivity().openOrCreateDatabase("MyDb",android.content.Context.MODE_PRIVATE ,null);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View InputFragmentView = inflater.inflate(R.layout.favourite, container, false);
Cursor c=db.rawQuery("select DISTINCT thumb from image",null);
Cursor c1=db.rawQuery("select DISTINCT title,id from vdetail",null);
title_array = new String[c1.getCount()];
id_array = new String[c1.getCount()];
img_array=new Bitmap[c.getCount()];
int i = 0;
if (c.moveToFirst()&&c1.moveToFirst()) {
do {
byte[] imagess = c.getBlob(0);
Bitmap bm = BitmapFactory.decodeByteArray(imagess, 0, imagess.length);
String title = c1.getString(0);
String id = c1.getString(1);
title_array[i] = title;
id_array[i] = id;
img_array[i] = bm;
i++;
Log.d("getting data", "on retrieving: ");
} while (c.moveToNext()&&c1.moveToNext());
}
gv = (GridView) InputFragmentView.findViewById(R.id.fav_gv);
gv.setAdapter(new FavourtireAdapter(getActivity(),title_array,id_array,img_array));
gv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Log.d("OK", "onItemLongClick: ");
return false;
}
});
return InputFragmentView;
}
}
gridview的項目,請點擊聽衆就是我想要顯示的對話框
這是什麼問題?您可以使用alertdialog。 – Sandeep