方法一:

// 软件设置

TextView hcsz1 = new TextView(
ComicLivePlayerApp.this);
hcsz1.setTextSize(25);
hcsz1.setText("缓冲设置");

TextView zdsz1 = new TextView(
ComicLivePlayerApp.this);
zdsz1.setTextSize(25);
zdsz1.setText("振动设置");

TextView yxsz1 = new TextView(
ComicLivePlayerApp.this);
yxsz1.setTextSize(25);
yxsz1.setText("音效设置");


String[] hcsz = new String[] { "大", "中","小" };
String[] zdsz = new String[] { "开", "关" };
String[] yxsz = new String[] { "开", "关" };

Spinner sphcsz = null;
Spinner spzdsz = null;
Spinner spyxsz = null;//需要用spinner
ArrayAdapter<String> adapterhcsz;
ArrayAdapter<String> adapterzdsz;
ArrayAdapter<String> adapteryxsz; //需要用arrayAdapter

LinearLayout.LayoutParams LP_FF = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT); //布局

sphcsz = new Spinner(
ComicLivePlayerApp.this);
sphcsz.setLayoutParams(LP_FF); //设置布局

adapterhcsz = new ArrayAdapter<String>(
ComicLivePlayerApp.this,
android.R.layout.simple_list_item_1,
hcsz); //string数组转换成arrayAdapter

sphcsz.setAdapter(adapterhcsz);//arrayAdapter添加到spinner

//spinner设置监听
sphcsz.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {

@Override
public void onItemSelected(
AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
hcsz_set = arg2;
}

@Override
public void onNothingSelected(
AdapterView<?> arg0) {
// TODO Auto-generated method stub

}
});

//监听完毕

//第二个string数组

spzdsz = new Spinner(
ComicLivePlayerApp.this);
spzdsz.setLayoutParams(LP_FF);
adapterzdsz = new ArrayAdapter<String>(
ComicLivePlayerApp.this,
android.R.layout.simple_list_item_1,
zdsz);
spzdsz.setAdapter(adapterzdsz);
spzdsz.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {

@Override
public void onItemSelected(
AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
zdsz_set = arg2;
}

@Override
public void onNothingSelected(
AdapterView<?> arg0) {
}
});

//第三个string数组

spyxsz = new Spinner(
ComicLivePlayerApp.this);
spyxsz.setLayoutParams(LP_FF);
adapteryxsz = new ArrayAdapter<String>(
ComicLivePlayerApp.this,
android.R.layout.simple_list_item_1,
yxsz);
spyxsz.setAdapter(adapteryxsz);
spyxsz.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {

@Override
public void onItemSelected(
AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
yxsz_set = arg2;

}

@Override
public void onNothingSelected(
AdapterView<?> arg0) {
// TODO Auto-generated method stub

}
});

//把软件设置所有项都添加到布局中

final LinearLayout lyset1 = new LinearLayout(
ComicLivePlayerApp.this);


lyset1.setOrientation(LinearLayout.HORIZONTAL);

LinearLayout lyset2 = new LinearLayout(
ComicLivePlayerApp.this);


lyset2.setOrientation(LinearLayout.HORIZONTAL);

LinearLayout lyset3 = new LinearLayout(
ComicLivePlayerApp.this);


lyset3.setOrientation(LinearLayout.HORIZONTAL);

LinearLayout lyset5 = new LinearLayout(
ComicLivePlayerApp.this);


lyset5.setOrientation(LinearLayout.VERTICAL);

lyset1.addView(hcsz1);
lyset1.addView(sphcsz);

lyset2.addView(zdsz1);
lyset2.addView(spzdsz);

lyset3.addView(yxsz1);
lyset3.addView(spyxsz);
//

lyset5.addView(lyset1);
lyset5.addView(lyset2);
lyset5.addView(lyset3);

lyset5.setPadding(10, 10, 0, 0);

//将lyset5放入弹出框,弹出

new AlertDialog.Builder(
ComicLivePlayerApp.this)
.setTitle("软件设置")
.setView(lyset5) //把布局设进去
.setPositiveButton(
"确定",
new DialogInterface.OnClickListener() {

@Override
public void onClick(
DialogInterface arg0,
int arg1) {

com.index.comicliveSA.Data date = new com.index.comicliveSA.Data();

date.cacheSetup = (byte) hcsz_set;// 缓冲设置

switch (zdsz_set) { // 振动设置
case 0: // 开
Data.playVibrate = true;
break;
case 1: // 关
Data.playVibrate = false;
break;
}

switch (yxsz_set) { // 振动设置
case 0: // 开
Data.playVibrate = true;
break;
case 1: // 关
Data.playVibrate = false;
break;
}

date.refreshSetup = (byte) sysz_set;// 刷页设置

}
})
.setNegativeButton(
"取消",
new DialogInterface.OnClickListener() {

@Override
public void onClick(
DialogInterface arg0,
int arg1) {

setContentView(fl);
}
}).create().show();


}

}
}).show();

}

方法二:

searchDialog = new AlertDialog.Builder(MainActivityGroup.this).create();

searchDialog.setView(getLayoutInflater().inflate(R.layout.manhua_searchcartoon, null));

searchDialog.show();

searchDialog.getWindow().setGravity(Gravity.CENTER);

searchDialog.getWindow().setLayout(android.view.WindowManager.LayoutParams.FILL_PARENT

, android.view.WindowManager.LayoutParams.WRAP_CONTENT);

searchDialog.getWindow().setContentView(getLayoutInflater().inflate(R.layout.manhua_searchcartoon, null));

//R.layout.manhua_searchcartoon是定义好的布局

如:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:gravity="center"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:padding="20dip">

<LinearLayout

android:orientation="vertical"

android:background="@drawable/gridview_xml_background"

android:padding="15dip"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<EditText

android:background="@drawable/logininput2"

android:layout_height="wrap_content"

android:layout_width="fill_parent"

android:hint="请输入搜索关键字" />

<RadioGroup

android:layout_width="wrap_content"

android:layout_height="wrap_content">

<RadioButton

android:id="@+id/radio0"

android:text="按漫画名"

android:textSize="18dip"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:checked="true" />

<RadioButton

android:id="@+id/radio1"

android:text="按作者名"

android:textSize="18dip"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

</RadioGroup>

<RelativeLayout

android:id="@+id/relativeLayout1"

android:layout_width="fill_parent"

android:layout_height="wrap_content">

<Button

android:layout_height="wrap_content"

android:layout_width="wrap_content"

android:text="搜索"

android:textColor="#ffffff"

android:textSize="16dip"

android:id="@+id/button_search"

android:background="@drawable/cartoon_select_button"

android:layout_alignParentLeft="true" />

<Button

android:layout_height="wrap_content"

android:layout_width="wrap_content"

android:text="取消"

android:textColor="#ffffff"

android:textSize="16dip"

android:background="@drawable/cartoon_select_button"

android:layout_alignParentRight="true"

android:id="@+id/button_return" />

</RelativeLayout>

</LinearLayout>

</LinearLayout>

方法三:

searchDialog = new AlertDialog.Builder(MainActivityGroup.this).create();

searchDialog .settitle("test");

searchDialog .setMessage("testmessage");

searchDialog.show();

更多相关文章

  1. Android(安卓)TableLayout
  2. Android启动流程简析(三)
  3. Android:Android(安卓)Studio 优化
  4. android 画图之bitmap(一)
  5. Android(安卓)app ERR_UNKNOWN_URL_SCHEME
  6. android 下拉状态栏(SystemUI)常见修改记录
  7. [置顶] Android开发之将Edittext输入弹出的软键盘设置搜索确定键
  8. Android之Handler的postDelayed()方法的用法
  9. Android(安卓)MediaPlayer 常用方法介绍

随机推荐

  1. java关键字系列(2)static(内存角度分析,格式
  2. java中的几个线程池的使用
  3. RSSHelper正式开源
  4. 进度条(ProgressBar)拖动条(SeekBar)android
  5. java中一个极其强悍的新特性Stream(非常实
  6. Android(安卓)pm命令及使用
  7. 上不了线的小程序
  8. 再也不要对==和equals的区别有困惑了,保证
  9. Springboot整合mybatis(注解而且能看明白
  10. JDBC面试题都在这里