我用Google搜索了很多,甚至可以通过许多本网站的问题,走了,但我就是无法找到解决我的问题。
I have googled a lot and even gone through many of this website questions but I just can't find the solution to my problem.
我想创建一个进度对话框像below.But我不知道该怎么办it..I试图通过创建一个自定义进度对话框but..with,你只能修改内部微调外观之一。 。在我来说,我想修改它的布局......我怎样才能做到这一点?????
I want to create a Progress Dialog like the one below.But i don't understand how to do it..I have tried by creating a custom progress dialog but..with that you can only modify the inside spinner appearance..In my case i want to modify its layout...How can i achieve that...????
到现在我已经尝试以下...
Till now i have tried the following...
public class nextclass extends Activity {
Thread t;
ProgressBar dia;
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
MainActivity.progressDialog.dismiss();
setContentView(R.layout.nextclassview);
// requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
((Button) findViewById(R.id.button1))
.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
// progressDialog = findViewById(R.id.progressBar1);
new AuthenticateUserTask().execute();
}
});
}
private class AuthenticateUserTask extends AsyncTask<Void, Void, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
progressDialog = ProgressDialog.show(
nextclass.this, "","Sucessful", true);
/* progressDialog.setIndeterminate(true);
progressDialog.setIndeterminateDrawable(getResources()
.getDrawable(R.layout.customspinner));
*/
progressDialog = ProgressDialog.show(nextclass.this, "",
"Processing....", true);
progressDialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
}
protected void onPostExecute(String s) {
if (progressDialog.isShowing())
progressDialog.dismiss();
Intent my = new Intent(getApplicationContext(), CountTime.class);
startActivity(my);
}
@Override
protected String doInBackground(Void... params) {
// TODO Auto-generated method stub
try {
Thread.sleep(2000);![custom spinner][2]
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
}
参考的有关如何创建自定义对话框的细节此链接
WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();
WMLP.x = 100; //x position
WMLP.y = 100; //y position
dialog.getWindow().setAttributes(WMLP);
EDIT2: 做一个对话的活动与你的code。在它的样品如下
Make a Dialog Activity with your code in it sample is shown below
public class DialogActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(" ");
alertDialog.setMessage("");
alertDialog.setIcon(R.drawable.icon);
alertDialog.setButton("Accept", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.setButton2("Deny", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
}
}
和android的清单文件
and in android manifest file
android:theme="@android:style/Theme.Translucent.NoTitleBar"
或
AlertDialog.Builder builder = new AlertDialog.Builder(
new ContextThemeWrapper(context, R.style.popup_theme));
中的值文件夹:
in the values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="back_color">#ffffffff</color>
<style name="popup_theme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowBackground">@color/back_color</item>
<item name="android:colorBackground">@color/back_color</item>
</style>