• AlterDialog


    package com.bwie.sixgroup.humbert;

    import android.app.Activity;
    import android.os.Bundle;
    import android.support.v7.app.AlertDialog;
    import android.text.TextUtils;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;

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

    import bean.User;

    /**
     * Created by acer on 2016/7/13.
     */
    public class TiActivity extends Activity{

        private TextView ti;
        private AlertDialog alertDialog;
        private ListView listview;
        private String trim;
        private String trim1;
        private MyAdapter myAdapter;
        private ImageView f;
        private List<User> list;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_ti);

            listview = (ListView)findViewById(R.id.listview);


            list = new ArrayList<User>();

            f = (ImageView)findViewById(R.id.f);
            f.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
            ti = (TextView)findViewById(R.id.ti);
            ti.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                showDialog();
                }
            });

        }
        public void showDialog(){
            AlertDialog.Builder builder = new AlertDialog.Builder(TiActivity.this);
            View view = View.inflate(TiActivity.this, R.layout.dialog,null);
            final EditText dialog_wen = (EditText)view.findViewById(R.id.dialog_wen);
            final EditText dialog_bu = (EditText)view.findViewById(R.id.dialog_bu);
            Button btn_confrim = (Button)view.findViewById(R.id.btn_confrim);
            Button btn_Cancel = (Button)view.findViewById(R.id.btn_Cancel);
            btn_Cancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                alertDialog.dismiss();
                }
            });

           btn_confrim.setOnClickListener(new View.OnClickListener() {

               private User user;

               @Override
               public void onClick(View v) {
                   trim1 = dialog_wen.getText().toString().trim();
                   trim = dialog_bu.getText().toString().trim();
                   if(!TextUtils.isEmpty(trim) && !TextUtils.isEmpty(trim1)){
                           list.add(new User(trim,trim1));
                           alertDialog.dismiss();
                           Toast.makeText(TiActivity.this,"您还没有提问",Toast.LENGTH_SHORT).show();
                       }
                           qwe();
                           alertDialog.dismiss();

               }
           });
            builder.setView(view);
            alertDialog = builder.create();
            alertDialog.show();

        }
        public void qwe(){
            if(myAdapter == null){
                myAdapter = new MyAdapter();
                listview.setAdapter(myAdapter);
            }else{
                myAdapter.notifyDataSetChanged();
            }
        }

        class MyAdapter extends BaseAdapter{

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

            @Override
            public Object getItem(int position) {
                return null;
            }

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

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                convertView = View.inflate(TiActivity.this, R.layout.tilistitem,null);
                TextView ti_ti = (TextView)convertView.findViewById(R.id.ti_ti);
                TextView ti_tv = (TextView) convertView.findViewById(R.id.ti_tv);

                ti_ti.setText(list.get(position).getNames());
                ti_tv.setText(list.get(position).getName());

                return convertView;
            }
        }
    }

  • 相关阅读:
    用vuex写了一个购物车H5页面的示例代码
    css如何引入外部字体?
    移动开发中更好的图片自适应
    常见样式问题七、word-break、word-wrap、white-space区别
    你真的了解word-wrap和word-break的区别吗?
    css中word-break、word-wrap和white-space的区别
    另辟蹊径:vue单页面,多路由,前进刷新,后退不刷新
    应该用forEach改变数组的值吗? 原生JS forEach()和map()遍历的异同点
    Vue 全家桶介绍
    Spring MVC配置MyBatis输出SQL
  • 原文地址:https://www.cnblogs.com/3674-it/p/5683504.html
Copyright © 2020-2023  润新知