[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();
}
});
}
}
by: 发表于:2017-07-13 11:01:13 顶(0) | 踩(0) 回复
??
回复评论