[android]代码库
1.MainActivity.java
package com.example.acer.myapplication;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView resultText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
resultText = (TextView) findViewById(R.id.edit);
}
public void onClick(View v) {
MyCustomDialog dialog = new MyCustomDialog(this,"输入",new MyCustomDialog.OnCustomDialogListener() {
@Override
public void back(String name) {
resultText.setText("你输入的是 "+name);
}
});
dialog.show();
}
}
2.activity_main.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:orientation="vertical" >
<EditText
android:id="@+id/edit"
android:layout_width="250dip"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/clickbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click me"
android:onClick="onClick" />
</LinearLayout>