0
Gridview에서 팝업되는 대화 상자 안의 버튼을 어떻게 클릭 할 수 있습니까? 아이템을 클릭합니다. 그리고이 격자보기는 조각 안에 있습니까?항목을 클릭하면 gridview에서 팝업되는 대화 상자 안의 버튼을 클릭하십시오.이 gridview는 조각 안에 있습니다
이 확인 버튼에 대해 onclicklistener를 생성 할 수 없습니다. 오류 힌트 : 이 유형보기의 방법 setOnClickListener (View.OnClickListener)가 인수 적용되지 않습니다() (새 DialogInterface.OnClickListener {})
다음내 코드입니다 :
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.MotionEventCompat;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class DiningFragment extends Fragment{
GridView gridView;
TextView Details1;
TextView Details2;
static final String[] NAMES = new String[] { "aroma", "aura", "crave",
"urbanbean", "flava", "map" };
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View inflatedView = inflater.inflate(R.layout.dining, container,
false);
Details1 = (TextView) inflatedView.findViewById(R.id.dining_details1);
Details2 = (TextView) inflatedView.findViewById(R.id.dining_details2);
gridView = (GridView) inflatedView.findViewById(R.id.gridView);
gridView.setAdapter(new DiningAdapter(getActivity(), NAMES));
String textLinks1 = "tesetestsetest";
String textLinks2 = "testtest";
if (Details1 != null) {
// set text to text view
Details1.setText(textLinks1);
Linkify.addLinks(Details1, Linkify.ALL); // linkify all links in
// text.
// you can set link color with the help of text view property
Details1.setLinkTextColor(Color.BLUE);
}
if (Details2 != null) {
// set text to text view
Details2.setText(textLinks2);
Linkify.addLinks(Details2, Linkify.ALL); // linkify all links in
// text.
// you can set link color with the help of text view property
Details2.setLinkTextColor(Color.BLUE);
}
gridView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(
getActivity().getApplicationContext(),
((TextView) v.findViewById(R.id.dining_label))
.getText(), Toast.LENGTH_SHORT).show();
**// dialog
final Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.dining_dialog);
dialog.setTitle("Title...");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.dining_dialogtext);
text.setText("Android custom dialog example!");
ImageView image = (ImageView) dialog.findViewById(R.id.dining_dialogimage);
image.setImageResource(R.drawable.ic_launcher);
Button dialogButton = (Button) dialog.findViewById(R.id.dining_dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();**
}
});
return inflatedView;
}
}