android 自定义dialog 多选项对话框

最近做的launcher项目里一个显示对话框效果。好多朋友都问我要代码,所以今天抽了点时间把这段代码扣出来,分享给大家《转帖的朋友,请标明出处,尊重作者的劳动成果》。上图吧
android 自定义dialog 多选项对话框

 

android 自定义dialog 多选项对话框

代码相对较多些,我就不一一阐述。项目里抠出来的,一些没必要的也都在里边了。使用作法如下

  1. public class MainActivity extends Activity implements OnCorpusSelectedListener {  
  2.     public CorpusSelectionDialog mCorpusSelectionDialog;  
  3.     private List<Corpus> mAppCategoryList;  
  4.   
  5.     @Override  
  6.     public void onCreate(Bundle savedInstanceState) {  
  7.         super.onCreate(savedInstanceState);  
  8.         setContentView(R.layout.main);  
  9.         initData();  
  10.         Button b = (Button) this.findViewById(R.id.button1);  
  11.         b.setOnClickListener(new OnClickListener() {  
  12.             @Override  
  13.             public void onClick(View v) {  
  14.                 showCorpusSelectionDialog();  
  15.             }  
  16.         });  
  17.     }  
  18.   
  19.     @Override  
  20.     public void onCorpusSelected(Corpus corpus) {  
  21.         Toast.makeText(this, corpus.label + "被点了", Toast.LENGTH_LONG).show();  
  22.     }  
  23.   
  24.     /** 
  25.      * 显示自定义dialog 
  26.      */  
  27.     protected void showCorpusSelectionDialog() {  
  28.         if (mCorpusSelectionDialog == null) {  
  29.             mCorpusSelectionDialog = new CategoryAppDialog(this,  
  30.                     mAppCategoryList);  
  31.             mCorpusSelectionDialog.setOwnerActivity(this);  
  32.             mCorpusSelectionDialog.setOnCorpusSelectedListener(this);  
  33.         }  
  34.         mCorpusSelectionDialog.show();  
  35.     }  

源码:http://download.csdn.net/detail/lnb333666/4471241

上一篇:Linux学习


下一篇:maya 7.0 渲染基础之ipr渲染教程