普通对话框
dialog
package com.example.app4;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private ListView list1;
private MyAdapter myAdapter;
private ArrayAdapter adapter = null;
private List<JavaBean.DataBean> lists = new ArrayList<>();
private String path="http://www.qubaobei.com/ios/cf/dish_list.php?stage_id=1&limit=20&page=1";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list1 = (ListView) findViewById(R.id.list1);
List<String> list = new ArrayList<>();
for (int i = 0; i < lists.size(); i++) {
list.add(lists.get(i).getTitle());
}
adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,list);
list1.setAdapter(adapter);
}
}
package com.example.app3;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class Main2Activity extends AppCompatActivity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
button = findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MyDialog myDialog = new MyDialog(Main2Activity.this);
myDialog.setMyTitle("换一个");
myDialog.setMyMessage("我看着泪流不止");
myDialog.setYes("qd");
myDialog.setNo("qx");
myDialog.setYesss("多多",new MyDialog.Yesss() {
@Override
public void Onclick() {
Toast.makeText(Main2Activity.this, "oo", Toast.LENGTH_SHORT).show();
}
});
myDialog.setNoooo("qc",new MyDialog.Noooo() {
@Override
public void Onclick() {
Toast.makeText(Main2Activity.this, "ooo", Toast.LENGTH_SHORT).show();
}
});
myDialog.create();
myDialog.show();
}
});
}
public void click(View view) {
switch (view.getId()){
case R.id.radio1:
Intent intent = new Intent(Main2Activity.this,MainActivity.class);
startActivity(intent);
break;
case R.id.radio2:
break;
}
}
}
package com.example.app3;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MyDialog extends Dialog {
private TextView Title1;
private TextView Message1;
private Button button11;
private Button button12;
private String MyTitle;
private String MyMessage;
private String Yes;
private String No;
private Yesss yesss;
private Noooo noooo;
public interface Yesss{
void Onclick();
}
public interface Noooo{
void Onclick();
}
public void setYesss(String name,Yesss yesss) {
this.Yes = name;
this.yesss = yesss;
}
public void setNoooo(String name,Noooo noooo) {
this.No = name;
this.noooo = noooo;
}
public void setMyTitle(String myTitle) {
MyTitle = myTitle;
}
public void setMyMessage(String myMessage) {
MyMessage = myMessage;
}
public void setYes(String yes) {
Yes = yes;
}
public void setNo(String no) {
No = no;
}
public MyDialog(Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item);
Title1 = (TextView) findViewById(R.id.Title1);
if (MyTitle!=null){
Title1.setText(MyTitle);
}
Message1 = (TextView) findViewById(R.id.Message1);
if (MyMessage!=null){
Message1.setText(MyMessage);
}
button11 = (Button) findViewById(R.id.button11);
if (Yes!=null){
button11.setText(Yes);
}
button12 = (Button) findViewById(R.id.button12);
if (No!=null){
button12.setText(No);
}
button11.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
yesss.Onclick();
dismiss();
}
});
button12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
noooo.Onclick();
dismiss();
}
});
}
}