LayoutInflater factory = LayoutInflater.from(context);
View view_img_mood = factory.inflate(R.layout.layout_img_mood, null);
GridView gv_img_mood = (GridView) view_img_mood.findViewById(R.id.gv_img_mood);
gv_img_mood.setAdapter(new Adapter_img_mood(this));
//使GridView的點選有作用
gv_img_mood.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
Toast.makeText(context, String.valueOf(position), Toast.LENGTH_SHORT).show();
//使有底框色
gv_img_mood.getChildAt(position).setBackgroundColor(getResources().getColor(R.color.paleyellow));
}
});
new AlertDialog.Builder(this)
.setView(view_img_mood)
.setPositiveButton("ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
Log.d("522", "ok");
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
Log.d("522", "cancel");
}
})
.show();
沒有留言:
張貼留言