0
버튼을 터치하고 팝업 윈도우를 디스플레이하는 앱이 있습니다. 그것은 다음과 같은 레이아웃입니다 내부 :안드로이드 PopUpWindow는 두 개의 버튼, textView와 TextEdit을 가지고 있습니다.
popupip.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="@drawable/popup_border" >
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dirección IP: " />
<TextView
android:id="@+id/ip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/dir_ip" />
</LinearLayout>
<EditText
android:id="@+id/new_ip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@android:color/white"
android:text="@string/nuevaip" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/guardar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="Guardar"
android:onClick="guardarip" />
<Button
android:id="@+id/salir"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Salir" />
</LinearLayout>
</LinearLayout>
버튼 salir
는 버튼을 기각한다. 또한 textedit보기에서 일부 텍스트를 쓰고 싶습니다. 그래서 guardar
단추를 터치하면 문자열에 저장되고 텍스트보기 ip
에 저장됩니다. 는 또한 팝업에 대한 다음과 같은 코드가 있습니다
Activity_main.java을
@Override
protected void onCreate(Bundle savedInstanceState) {
final Button botonip = (Button)findViewById(R.id.btn_ip);
botonip.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popupip, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.salir);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
popupWindow.dismiss();
}});
popupWindow.showAsDropDown(botonip, 50, -30);
}});
}
내 질문에 I를 할 수있는 팝업에서 다른 요소에 대해 둘 이상의 popupView.finViewById를 사용하거나하는 방법을 할 수있는 경우이다 버튼, textView 및 TextEdit 처리?