80,361
社区成员
发帖
与我相关
我的任务
分享
public class FunGamepad extends Activity implements OnClickListener {
private Button btn1, btnSet;
String Str_btn_1;
EditText setbtn_et_1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自动生成的方法存根
super.onCreate(savedInstanceState);
setContentView(R.layout.gamepad);
btnSet = (Button) findViewById(R.id.gameepad_btnSet);
btn1 = (Button) findViewById(R.id.gameepad_Btn1);
setbtn_et_1 = (EditText) findViewById(R.id.gamepad_setbtn_et_1);
btnSet.setOnClickListener(this);
btn1.setOnClickListener(this);
}
@Override
// 按钮监听
public void onClick(View v) {
// TODO 自动生成的方法存根
switch (v.getId()) {
case R.id.gameepad_btnSet: Gamepad_BtnSet();
break;
}
}
public void Gamepad_BtnSet() {
// 创建选择"按键设置"后显示的对话框
AlertDialog.Builder builder1 = new Builder(
FunGamepad.this);
LayoutInflater layoutInflater = LayoutInflater
.from(FunGamepad.this);
View gamepad_setbtn = layoutInflater.inflate(
R.layout.gamepad_setbtn, null);
builder1.setTitle("设置按钮")
.setView(gamepad_setbtn)
.setPositiveButton(
"确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int i) {
// 按下确定以后进行的操作
try {
// 获得设置按钮文本框中的文字
Str_btn_1 = setbtn_et_1.getText().toString();
// 按钮上的文字换成设置后的文字
btn1.setText(Str_btn_1);
}
catch (Exception e)
{
Toast.makeText(getApplication(),e.toString() ,Toast.LENGTH_LONG).show();
}
}
})
.setNegativeButton(
"取消",
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,int i) {
// 按下取消以后关闭
dialog.dismiss();
}
}).create().show();
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.top.MainActivity"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:layout_marginTop="30dp"
android:paddingLeft="45dp"
android:paddingRight="45dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="用户名"/>
<TextView
android:textSize="20sp"
android:id="@+id/user_userXinxi"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"
android:text="userName"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="头像"/>
<LinearLayout
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="4.00"
android:gravity="left"
android:layout_height="76dp">
<ImageView
android:id="@+id/img_userXinxi"
android:src="@drawable/ic_launcher"
android:layout_width="90dp"
android:layout_height="76dp"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="学校"/>
<EditText
android:id="@+id/school_userXinxi"
android:lines="1"
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="院系"/>
<EditText
android:id="@+id/yuanxi_userXinxi"
android:lines="1"
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:text="手机号"/>
<EditText
android:id="@+id/phone_userXinxi"
android:textSize="20sp"
android:layout_width="0dp"
android:lines="1"
android:layout_weight="4"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textSize="20sp"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"
android:text=" "/>
<EditText
android:id="@+id/yanZhengMa_userXinxi"
android:textSize="15sp"
android:hint="手机验证码"
android:lines="1"
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btnYZM_userXinxi"
android:text="发送验证码"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tijiao_userXinxi"
android:text="提交"
android:textSize="30dp"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>