Day01 对对话框的一些知识点以及自定义对话框的实现

Day01 Dialog对话框

Day01 Dialog对话框

1、常用的对话框

布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <Button
        android:id="@+id/button01"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="确定取消对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button02"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="单选对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button03"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="多选对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button06"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="自定义对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button04"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="进度对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button05"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="进度条对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button07"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="日期选择对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button08"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="时间对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button09"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="自定义对话框"
        android:onClick="click"/>
    <Button
        android:id="@+id/button10"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="跳转"
        android:onClick="click"/>
</LinearLayout>

代码

package com.liuqiang.day01;

import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.Toast;

import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {
    private Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what==1){
                int progress = msg.arg1;
                ProgressDialog progressDialog = (ProgressDialog) msg.obj;
                progressDialog.setProgress(progress);
                progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                progressDialog.setMax(100);
                progressDialog.setMessage("正在下载");
                progressDialog.show();
                if(progress==100){
                    progressDialog.dismiss();

                }
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }
    public void click(View view) {
        switch(view.getId()){
            case R.id.button01:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setIcon(R.mipmap.ic_launcher);
                builder.setTitle("what?");
                builder.setMessage("wocao");
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了确定", Toast.LENGTH_SHORT).show();

                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了取消", Toast.LENGTH_SHORT).show();
                    }

                });
                AlertDialog alertDialog1 = builder.create();
                alertDialog1.show();
                break;
            case R.id.button02:
                AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
                builder1.setIcon(R.mipmap.ic_launcher);
                builder1.setTitle("卧槽无情");
                builder1.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了确定", Toast.LENGTH_SHORT).show();

                    }
                });
                builder1.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了取消", Toast.LENGTH_SHORT).show();
                    }

                });
                final String[] items={"男人","女人","女博士"};
                builder1.setSingleChoiceItems(items, 1, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你选中的是"+items[which], Toast.LENGTH_SHORT).show();
                    }
                });
                AlertDialog alertDialog = builder1.create();
                alertDialog.show();
                break;
            case R.id.button03:
                final String[] items1={"红","蓝","绿","紫"};
                final boolean[] flags={true,true,true,false};
                AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
                builder2.setIcon(R.mipmap.ic_launcher);
                builder2.setTitle("卧槽无情");
                builder2.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        for (int i = 0; i < flags.length; i++) {
                            if(flags[i]){
                                Toast.makeText(MainActivity.this, "你选择了"+items1[i], Toast.LENGTH_SHORT).show();
                            }
                        }
                    }
                });
                builder2.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "取消", Toast.LENGTH_SHORT).show();
                    }
                });
                builder2.setMultiChoiceItems(items1, flags, new DialogInterface.OnMultiChoiceClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                        flags[which]=isChecked;
                    }
                });
                AlertDialog alertDialog2 = builder2.create();
                alertDialog2.show();
                break;
            case R.id.button06:
                View view1 = LayoutInflater.from(this).inflate(R.layout.activity_custom, null);
               ;
                AlertDialog.Builder builder3 = new AlertDialog.Builder(this);
                builder3.setIcon(R.mipmap.ic_launcher);
                builder3.setTitle("标题");
                builder3.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了确定", Toast.LENGTH_SHORT).show();
                    }
                });
                builder3.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this, "你点击了取消", Toast.LENGTH_SHORT).show();
                    }
                });
                builder3.setView(view1);
                AlertDialog alertDialog3 = builder3.create();
                alertDialog3.show();
                break;
            case R.id.button07:
                Calendar calendar = Calendar.getInstance();
                new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                        Toast.makeText(MainActivity.this, year+"-"+(month-1)+"-"+dayOfMonth, Toast.LENGTH_SHORT).show();
                    }
                },calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)).show();
            case R.id.button08:
                break;
            case R.id.button05:
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        int progress=0;
                        ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
                        progress+=20;
                        Message message = new Message();
                        message.what=1;
                        message.arg1=progress;
                        message.obj=progressDialog;
                        handler.sendMessage(message);
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
                break;
            case R.id.button09:
                MyDialog myDialog = new MyDialog(this);
                myDialog.show();
                myDialog.setusernametext("wocao");
                myDialog.onclicklogin(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(MainActivity.this, "你点击了登陆", Toast.LENGTH_SHORT).show();
                    }
                });


                break;
            case R.id.button10:
                Intent intent = new Intent(this, Main2Activity.class);
                startActivity(intent);
                break;
            default:

            break;
        }

    }
}

技能二:自定义对话框
在这里插入图片描述
1.点击底部的按钮弹出评级对话框
2.,实现如图所示的对话框的样式
3,点击对话中相应的按钮进行吐司提示
4.对话框中右上角图标点击关闭弹框

package com.liuqiang.app2;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private RadioGroup radiogroup;
    private RadioButton button01;
    private RadioButton button02;
    private static final String TAG = "MainActivity";
    private ImageView one;
    private RelativeLayout two;
    private RadioButton Rbutton01;
    private RadioButton RButton02;

    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        one = (ImageView) findViewById(R.id.one);
        two = (RelativeLayout) findViewById(R.id.two);
        Rbutton01 = (RadioButton) findViewById(R.id.Rbutton01);
        RButton02 = (RadioButton) findViewById(R.id.RButton02);

        radiogroup = (RadioGroup) findViewById(R.id.radiogroup);
        button01 = (RadioButton) findViewById(R.id.button01);
        button02 = (RadioButton) findViewById(R.id.button02);
        radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
               if(button01.isChecked()){
                    one.setVisibility(View.VISIBLE);
               }else{
                    one.setVisibility(View.GONE);
               }
               if(button02.isChecked()){
                    two.setVisibility(View.VISIBLE);
               }else{
                   two.setVisibility(View.GONE);
               }
            }
        });

    }

    public void click(View view) {
        MyDialog myDialog = new MyDialog(this);
        myDialog.show();
        myDialog.setOnclick();
    }
}

package com.liuqiang.app2;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MyDialog extends Dialog {
    private Context context;
    private RadioGroup select;
    private RadioButton Rbutton01;
    private RadioButton RButton02;


    public MyDialog(Context context) {
        super(context,R.style.what);
        this.context=context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(context).inflate(R.layout.layout_divdialog, null);
        select = view.findViewById(R.id.select);
        Rbutton01 = view.findViewById(R.id.Rbutton01);
        RButton02 = view.findViewById(R.id.RButton02);
        setContentView(view);
    }
    public void setOnclick(){
        select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(Rbutton01.isChecked()){
                    Toast.makeText(context, "我要吐槽", Toast.LENGTH_SHORT).show();
                }else if(RButton02.isChecked()){
                    Toast.makeText(context, "五星好评", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/one"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:src="@mipmap/a"
        android:checked="true"
        android:visibility="visible"/>
    <RelativeLayout
        android:id="@+id/two"
        android:visibility="gone"
        android:layout_width="match_parent"
        android:layout_height="680dp"
        >
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:src="@mipmap/b"
            android:scaleType="fitXY"/>
        <Button
            android:layout_alignParentBottom="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="评一评"
            android:onClick="click"
            />
    </RelativeLayout>
        <RadioGroup
            android:id="@+id/radiogroup"
            android:gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <RadioButton
                android:id="@+id/button01"
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:button="@null"
                android:checked="true"
                android:text="首页"

                android:textColor="@drawable/button01"
                android:gravity="center"/>
            <RadioButton
                android:id="@+id/button02"
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:button="@null"

                android:textColor="@drawable/button01"
                android:text="我的"
                android:gravity="center"/>
        </RadioGroup>


</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="430dp"
    android:layout_gravity="center"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:background="#12B6FF"
        android:orientation="horizontal"
        android:layout_height="200dp">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="评价一下吧!"
            android:gravity="center"
            android:textSize="30sp"
            android:textColor="#ffffff"
            android:layout_marginTop="30dp"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="150dp">
        <TextView
            android:textSize="20sp"
            android:layout_width="wrap_content"
            android:text="喜欢吗?给个五星好评,鼓励"
            android:layout_gravity="center"
            android:layout_marginTop="50dp"
            android:layout_height="wrap_content" />
        <TextView
            android:textSize="20sp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="我们值得更好!"
            android:layout_gravity="center"
            />

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="match_parent">
        <RadioGroup
            android:id="@+id/select"
            android:gravity="bottom"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/Rbutton01"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="我要吐槽"
                android:textColor="@drawable/index_text"
                />

            <RadioButton
                android:id="@+id/RButton02"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:button="@null"
                android:gravity="center"
                android:text="五星好评"
                android:checked="true"
                android:textColor="@drawable/text01"
                />
        </RadioGroup>

    </LinearLayout>



</LinearLayout>

使用ListView显示本班级的任意十个同学的信息,信息包括同学的姓名、头像、电话号码,点击第一个同学的时候使用AlertDialog显示他的信息,点击第二个同学的时候使用DatePickerDialog显示当前的日期,点击第三个同学的时候弹出是否删除对话框,当点击确定删除该同学。

评分标准:
1,创建ListView(10分)
2,创建适配器(10分)
3,ListView优化(15分)
4,创建AlerDalog(15分)
5,创建DatePickerDialog(15分)
6,自动Dialog菜单(15分)
7,创建工程(10分)
8,注释(10分)

package com.liuqiang.app3;

import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.CalendarView;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.Toast;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private List<Student.Data1Bean> list=new ArrayList<>();
    private Adapter myadpter;
    private ListView listview;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listview = (ListView) findViewById(R.id.listview);
        JavaBean[] javaBeans=new JavaBean[]{
                new JavaBean("轩总","http://www.qubaobei.com/ios/cf/uploadfile/132/9/8289.jpg","13076781033"),
        new JavaBean("浩文","http://www.qubaobei.com/ios/cf/uploadfile/132/3/2127.jpg","13076781033"),
        new JavaBean("鹏","http://www.qubaobei.com/ios/cf/uploadfile/132/31/30630.jpg","13076781033"),
        new JavaBean("海王","http://www.qubaobei.com/ios/cf/uploadfile/132/10/9073.jpg","13076781033"),
        new JavaBean("轩总","http://www.qubaobei.com/ios/cf/uploadfile/132/11/10097.jpg","13076781033"),
        new JavaBean("卡航","http://www.qubaobei.com/ios/cf/uploadfile/132/11/10509.jpg","13076781033"),
                new JavaBean("花猪","http://www.qubaobei.com/ios/cf/uploadfile/132/47/46968.jpg","13076781033"),
        new JavaBean("黑猪","http://www.qubaobei.com/ios/cf/uploadfile/132/11/10191.jpg","13076781033"),
        new JavaBean("超泽","http://www.qubaobei.com/ios/cf/uploadfile/132/3/2372.jpg","13076781033"),
        };
        Gson gson = new Gson();
        String s = gson.toJson(javaBeans);
        Log.i("TAG", "onCreate: "+"{'data1':" + s + "}");
        Student student = gson.fromJson("{'data1':" + s + "}", Student.class);
        final List<Student.Data1Bean> data1 = student.getData1();
        list.addAll(data1);
        final MyAdapter myAdapter = new MyAdapter(list, this);
        listview.setAdapter(myAdapter);
        listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                if(position==0){
                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

                    builder.setMessage(list.get(position).getName()+list.get(position).getPhone());
                    AlertDialog alertDialog = builder.create();
                    alertDialog.show();
                }else if(position==1){
                    Calendar instance = Calendar.getInstance();
                    new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                            Toast.makeText(MainActivity.this, year+"-"+(month+1)+"-"+dayOfMonth, Toast.LENGTH_SHORT).show();
                        }
                    },instance.get(Calendar.YEAR),instance.get(Calendar.MONTH),instance.get(Calendar.DAY_OF_MONTH)).show();
                }else if(position==2){
                    AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
                    builder1.setTitle("你确定要删除吗?");
                    builder1.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            list.remove(position);
                            myAdapter.notifyDataSetChanged();
                        }
                    });
                    builder1.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
                    AlertDialog alertDialog = builder1.create();
                    alertDialog.show();
                }

            }
        });

    }
}

package com.liuqiang.app3;

public class JavaBean {
    private String name;
    private String img;
    private String phone;

    public JavaBean() {
    }

    public JavaBean(String name, String img, String phone) {

        this.name = name;
        this.img = img;
        this.phone = phone;
    }

    public String getName() {

        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}

package com.liuqiang.app3;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

public class MyAdapter extends BaseAdapter {
    private List<Student.Data1Bean> list;
    private Context context;

    public MyAdapter(List<Student.Data1Bean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.activity_item,null);
            viewHolder.imageView=convertView.findViewById(R.id.image1);
            viewHolder.phone=convertView.findViewById(R.id.telephone);
            viewHolder.name=convertView.findViewById(R.id.name);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }
        viewHolder.name.setText(list.get(position).getName());
        viewHolder.phone.setText(list.get(position).getPhone());
        Glide.with(context).load(list.get(position).getImg()).into(viewHolder.imageView);
        return convertView;
    }
    class ViewHolder{
        ImageView imageView;
        TextView phone,name;
    }
}

package com.liuqiang.app3;

import java.util.List;

public class Student {

    private List<Data1Bean> data1;

    public List<Data1Bean> getData1() {
        return data1;
    }

    public void setData1(List<Data1Bean> data1) {
        this.data1 = data1;
    }

    public static class Data1Bean {
        /**
         * img : http:\/\/www.qubaobei.com\/ios\/cf\/uploadfile\/132\/9\/8289.jpg
         * name : 轩总
         * phone : 13076781033
         */

        private String img;
        private String name;
        private String phone;

        public String getImg() {
            return img;
        }

        public void setImg(String img) {
            this.img = img;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }
    }
}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/image1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@mipmap/ic_launcher"/>
    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/image1"
        android:text="姓名"
        android:textSize="25sp"/>
    <TextView
        android:id="@+id/telephone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="电话号码"
        android:layout_below="@+id/name"
        android:layout_toRightOf="@id/image1"
        android:layout_marginTop="30dp"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

   <ListView
       android:id="@+id/listview"
       android:layout_width="match_parent"
       android:layout_height="match_parent">

   </ListView>

</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值