Created
October 29, 2014 21:30
-
-
Save lu911/678182c135ed736fc1e0 to your computer and use it in GitHub Desktop.
example.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.androidta_refort; | |
public class MainActivity extends Activity { | |
RadioGroup rg; | |
ImageView iv;@ | |
Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
final TextView rtv = (TextView) findViewById(R.id.dtv); | |
final TextView rtv2 = (TextView) findViewById(R.id.dtv2); | |
iv = (ImageView) findViewById(R.id.imageView1); | |
Button btn = (Button) findViewById(R.id.button1); | |
// --- | |
final Builder bd = new Builder(MainActivity.this); // 자신 객체 호출 | |
final LinearLayout dia = (LinearLayout) View.inflate(getBaseContext(), | |
R.layout.dialog_list, null); | |
bd.setView(dia); | |
TextView tv = (TextView) dia.findViewById(R.id.tv1); | |
final EditText et = (EditText) dia.findViewById(R.id.editText1); | |
final TextView tv2 = (TextView) dia.findViewById(R.id.textView2); | |
final EditText et2 = (EditText) dia.findViewById(R.id.editText2); | |
rg = (RadioGroup) dia.findViewById(R.id.radioGroup1); | |
final RadioButton rb1 = (RadioButton) dia.findViewById(R.id.radio0); | |
final RadioButton rb2 = (RadioButton) dia.findViewById(R.id.radio1); | |
final RadioButton rb3 = (RadioButton) dia.findViewById(R.id.radio2); | |
btn.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View v) { | |
bd.setIcon(R.drawable.ic_launcher); | |
bd.setTitle("input"); | |
bd.setPositiveButton("Cancle", | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, | |
int which) { | |
// TODO Auto-generated method stub | |
dialog.cancel(); | |
} | |
}); | |
bd.setNeutralButton("Ok", | |
new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, | |
int which) { | |
rtv.setText(et.getText().toString()); | |
rtv2.setText(et2.getText().toString()); | |
RadioButton rd = (RadioButton) findViewById(rg | |
.getCheckedRadioButtonId()); | |
switch (rg.getCheckedRadioButtonId()) { | |
case R.id.radio0: | |
iv.setVisibility(View.VISIBLE); | |
iv.setImageResource(R.drawable.img1); | |
Toast.makeText(getBaseContext(), | |
rb1.getText().toString() + "1", 0) | |
.show(); | |
break; | |
case R.id.radio1: | |
iv.setVisibility(View.VISIBLE); | |
iv.setImageResource(R.drawable.img2); | |
Toast.makeText(getBaseContext(), | |
rb2.getText().toString() + "2", 0) | |
.show(); | |
break; | |
default: | |
iv.setVisibility(View.VISIBLE); | |
iv.setImageResource(R.drawable.img3); | |
Toast.makeText(getBaseContext(), | |
rb3.getText().toString() + "3", 0) | |
.show(); | |
break; | |
} | |
} | |
}); | |
bd.show(); // ? | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment