나는 초보자입니다. 하나의 목록보기가 있습니다. 목록에서 항목을 클릭하면 피드로 사용할 수있는 알림 대화 상자가 열립니다. 너무 많은 단추, 회 전자, 텍스트 등을 편집 할 수 있으므로 작업으로 결정했습니다. .listview Item을 클릭하면 경고 대화 상자와 비슷한 내 활동을 어떻게 열 수 있습니까?
지금은 x32 파일을 만들었는지 여부는 작동 여부를 확인하기 위해 & 그 코딩을 할 것입니다. 이제 내 질문은 어떻게 alertdialog 상자로 만들 수 있으며 목록보기에서 항목을 클릭하면 열립니다.
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long rowId) {
final AlertDialog customDialog = new AlertDialog.Builder(SubMenu.this).create();
final LayoutInflater inflater = getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.popup
, null);
customDialog.setView(dialogView);
// set the custom customDialogimation components - text, image and button
final TextView tvDistance = (TextView) dialogView.findViewById(R.id.h2);
final Button okbtn=(Button)dialogView.findViewById(R.id.ok) ;
okbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customDialog.dismiss();
}
});
final Button cnclbtn=(Button)dialogView.findViewById(R.id.canc) ;
cnclbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
customDialog.dismiss();
}
});
}
}
u는 위에서 볼 수 있듯이 나는 팝업을 사용하여 시도하지만, u는 클릭이나 버튼을 선택하면 thts가 작동하지 않는 등 여기
내 mydialog.xml입니다 : 여기 내 하위 메뉴 활동입니다 :<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#FFFFFF"
android:gravity="start"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/desimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/logo" />
<TextView
android:id="@+id/h1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small"
android:textSize="21sp"
android:textStyle="bold" />
<TextView
android:id="@+id/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Chicken Pizza Small Combo"
android:textColor="#8c8181"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="@+id/quant"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="3"
android:background="@drawable/mybtn"
android:text="Quantity"
android:textAllCaps="false"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="7"
android:background="@drawable/stroke_button"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/incr"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="-"
android:background="@color/colorwhite"
android:textColor="#FFA726"
android:textSize="25dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:text="5" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#c0c0c0" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/colorwhite"
android:gravity="center"
android:text="+"
android:textColor="#FFA726"
android:textSize="25dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:id="@+id/sl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="SL"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="S"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="M"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/L"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="l"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
<CheckBox
android:id="@+id/f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:buttonTint="#c0c0c0"
android:text="F"
android:textColor="#8c8181"
tools:targetApi="lollipop" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="#c0c0c0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/stroke_button"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<Spinner
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/stroke_button"
android:orientation="vertical"
android:paddingBottom="5dp"
android:paddingTop="5dp">
<Spinner
android:id="@+id/spinner2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp" />
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="SPECIAL INSTRUCTIONS"
android:textSize="16sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@drawable/stroke_button"
android:padding="@dimen/fab_margin1">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="top"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:maxLines="5"
android:padding="2dp"
android:textColor="#c0c0c0" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp">
<Button
android:id="@+id/canc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="@drawable/mybutton2"
android:text="Cancel"
android:textColor="#ffffff" />
<Button
android:id="@+id/ok"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/mybtn"
android:text="Ok"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
</ScrollView>
모든 목록보기 항목을 클릭하면 대화 상자로 표시됩니다. 친절하게 도와주세요.
getActivity()에 빨간색 선이 표시됩니다. –
제거하십시오. 내 편집 된 코드를 참조하십시오. –
네, 그 작업 ...하지만 여기서 대화 상자에서 모든 코딩 작업을 수행 할 수 있습니다. 서버에서 이미지를 호출해야하기 때문에 여기에 표시된 이미지는 데모 이미지이며,이 대화 상자에서만 할 수 있습니다. –