用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

AlertDialog

2016-12-19 作者: 张贤伟举报

[java]代码库

package com.example.day13_alerdialog;
 
import java.util.ArrayList;
import java.util.List;
 
import bean.Textview;
 
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
 
public class MainActivity extends Activity {
    private GridView gridView;
    private List<Textview> list=new ArrayList<Textview>();
    private Dialog dialog;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gridView=(GridView) findViewById(R.id.grid);
         
        for (int i = 0; i < 20; i++) {
            Textview textview=new Textview();
            textview.setImage(R.drawable.d);
            textview.setName("你好");
            list.add(textview);
        }
       Basetab basetab=new Basetab(this,list);
       gridView.setAdapter(basetab);
       gridView.setOnItemClickListener(new OnItemClickListener() {
 
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
            //aDialog = new AlertDialog.Builder(MainActivity.this)
            dialog=new AlertDialog.Builder(MainActivity.this).setTitle("请选择")
                    .setIcon(R.drawable.d).
                    setPositiveButton("下载", new DialogInterface.OnClickListener() {
                         
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            Toast.makeText(MainActivity.this, "你下载了", Toast.LENGTH_LONG).show();
                        }
                    }).setNegativeButton("删除", new DialogInterface.OnClickListener() {
                         
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            Toast.makeText(MainActivity.this, "你删除了", Toast.LENGTH_LONG).show();
                        }
                    }).create();
            dialog.show();
             
             
        }
    });
    }
 
 
    
     
}


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...