我已经尝试了很多方法来backPressed在progressDialog显示时触发()事件.但都没有效果.如果我提供progDialog.setcancelable(true);我能够解雇progressDialog但仍然onBackPressed()没有被触发.
我必须将我的项目的字体更改为外部的,我几乎无处不在,现在只有它缺少ProgressDialog和ErrorDialeg的标题(正文也被更改).
那么我在两种情况下都做了什么(由于Exception而发表了文本视图):
String msg1 = "one", msg2 = "two";
progressDialog = ProgressDialog.show(activity, msg1, msg2, true);
Typeface font=Typeface.createFromAsset(activity.getAssets(),"fonts/rockwell.ttf");
TextView text = (TextView)progressDialog.findViewById(android.R.id.message);
text.setTypeface(font);
//text = (TextView)progressDialog.findViewById(android.R.id.title);
text.setTypeface(font);
Run Code Online (Sandbox Code Playgroud)
和:
..........
AlertDialog dialog = new AlertDialog.Builder(a)
.setTitle( titol )
.setMessage( cos )
..........
.show();
//Establir el canvi de font a la personalitzada.
Typeface font=Typeface.createFromAsset(a.getAssets(),"fonts/rockwell.ttf");
TextView textView = (TextView)dialog.findViewById(android.R.id.message);
textView.setTypeface(font);
//textView = (TextView)dialog.findViewById(android.R.id.title);
textView.setTypeface(font);
textView = (TextView)dialog.findViewById(android.R.id.button1);
textView.setTypeface(font);
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有可能的选项(不仅是'R.id.title')而且我只有异常试图在两种情况下都获得TITLE TextView.这是我需要改变整个项目字体的最后一件事.如果有人知道在哪里获得标题...提前谢谢.
我希望进度条在匹配字符串时增加.就像我点击"是"一样,"是"栏会增加.但由于某种原因,我无法取得进展.
码:
public class result extends VoteActivity{
private ProgressBar mProgress;
private int mProgressStatus = 0;
private Handler mHandler = new Handler();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alert);
if(choice=="Yes")
{
mProgress = (ProgressBar) findViewById(R.id.p1);
// Start lengthy operation in a background thread
new Thread(new Runnable() {
public void run() {
++mProgressStatus;
// Update the progress bar
mHandler.post(new Runnable() {
public void run() {
mProgress.setProgress(mProgressStatus);
}
});
}
}).start();
}
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?
我从服务器获取一个 JSON,它是我的 ListView 的内容。一切都很好,但我想在调用 Json 时创建一个 ProgressDialog。问题是我需要在不同的线程中调用 JSON(使用 http 方法)并在 ListView 中向用户显示结果。
这就是我正在做的事情,但出现了错误"05-09 12:13:28.358: W/System.err(344): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views."
try {
final ProgressDialog progDailog;
progDailog =ProgressDialog.show(this,"HI", "Loading");
new Thread(new Runnable() {
@Override
public void run() {
try
{
JSONArray json = new JSONArray(executeHttpGet("http://m-devsnbp.insightlabs.cl/cuentos/json"));
progDailog.cancel();
ArrayList<HashMap<String, String>> talesList = new ArrayList<HashMap<String, String>>();
talesList = jsonToHash(json);
adapter = new LazyAdapter((Activity) ctx, talesList, 2);
list.setAdapter(adapter);
}
catch (InterruptedException e)
{
e.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud) 我有一个从数据库中提取数据并将其填充到列表中的过程.我想在执行查询时显示进度对话框,但只有在执行查询后才能直观显示.我相信我必须ProgressDialog在一个单独的线程中运行,但是没有提出任何建议,也无法使其工作.
所以在我的Activity身上
private void DisplayAllproductListView(String SqlStatement) {
ProgressDialog dialog =
ProgressDialog.show(MyActivity.context, "Loading", "Please wait...", true);
//..................
//..................
//execute sql query here
dialog.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
谢谢
所以我环顾四周,似乎如果我想制作某种加载指示器,我需要使用 AsyncTask。但是, ASyncTask 似乎更适合获取或插入数据。就我而言,我正在加载的活动有很多以编程方式生成的自定义视图。换句话说,这都是 UI 活动——所以我不能使用 ASyncTask,因为我不能在后台运行我的进程。我想显示一个进度对话框,以便用户知道正在加载新活动,而不仅仅是查看黑屏。有人知道这样做的方法吗?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// start the progress dialog here
for(int i = 0; i < 50; i++) {
// generate some textviews...
TextView tv = new TextView(this);
tv.setText("textview # " + i);
}
// dismiss the progress dialog
Run Code Online (Sandbox Code Playgroud)
}
我ProgressDialog没有显示 - 它在AsyncTask类BackgroundDataLoad中定义.
DialoguePopup类 -
public class DialoguePopup extends DialogFragment {
public DialoguePopup newInstace()
{
DialoguePopup dialogFragment = new DialoguePopup();
return dialogFragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
super.onCreateView(inflater, container, savedInstanceState);
//view related code..
//Calculation logic data load in background
new BackgroundDataLoad().execute();
return view;
}
class BackgroundDataLoad extends AsyncTask<String, String, String>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(getActivity());
pDialog.setMessage("Calculating ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
@Override
protected …Run Code Online (Sandbox Code Playgroud) 我正在使用FirebaseListAdapter,我需要显示ProgressDialog,但我不知道如何知道它何时完成加载.
public class TabFragment1 extends ListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.tab_fragment_1, container, false);
ListView eventosView = (ListView) rootView.findViewById(android.R.id.list);
Firebase ref = new Firebase(//myappurl);
Firebase usersRef = new Firebase(//myappurl/eventos/users);
Singleton singletonUser = Singleton.getInstance();
setUser(singletonUser);
Firebase ref = new Firebase(//myappurl/eventos);
FirebaseListAdapter<Evento> mAdapter = new FirebaseListAdapter<Evento>(getActivity(), Evento.class, R.layout.event_row, ref) {
@Override
protected void populateView(View view, Evento evento) {
((TextView)view.findViewById(R.id.eventTitle)).setText(evento.getNome());
((TextView)view.findViewById(R.id.eventPlace)).setText(evento.getLocal());
}
};
setListAdapter(mAdapter);
return mAdapter;
return rootView;
}
private void setUser(Singleton singletonUser){
singletonUser.getToken(); …Run Code Online (Sandbox Code Playgroud) 目前
我打开与画廊Intent,用户可以接着从后将该文件复制到指定文件夹的画廊视频.一切正常.
我希望ProgressBar在用户选择视频(在图库中)之后显示一个权限,然后progresbar.dismiss在文件完成复制后显示.
这是类似的问题,但没有答案(没有任何效果):
这就是我称之为画廊的方式:
public void selectVideoFromGallery()
{
Intent intent;
if(android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
{
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
}
else
{
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.INTERNAL_CONTENT_URI);
}
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra("return-data", true);
startActivityForResult(intent,SELECT_VIDEO_REQUEST);
}
Run Code Online (Sandbox Code Playgroud)
我在progressbar.show();这里试过(上图),但显然它会在选择视频之前开始显示.
这是我的OnActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == SELECT_VIDEO_REQUEST && resultCode == RESULT_OK)
{
if(data.getData()!=null)
{
//copy file to new folder
Uri selectedImageUri = data.getData();
String sourcePath = getRealPathFromURI(selectedImageUri); …Run Code Online (Sandbox Code Playgroud) 我有以下代码,在我执行长时间运行的任务之前,我启动了一个环形对话框,在 RxJava2 中完成。问题是对话框没有显示,我认为我没有阻塞主 UI 线程。
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ringProgressDialog != null) {
if (ringProgressDialog.isShowing()) {
ringProgressDialog.dismiss();
}
}
ringProgressDialog = ProgressDialog.show(SendConversationsActivity.this,
getResources().getString(R.string.creating_document_progress_dialog_title),
getResources().getString(R.string.conversation_progress_dialog_text),
true, false);
FileNameAndContacts filenameAndContacts = new FileNameAndContacts();
if (tvNoDatSelected.getVisibility() != View.VISIBLE) {
filenameAndContacts.setFileName("");
}
createDocument(filenameAndContacts)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnError(throwable -> Timber.e(throwable, "Error in getting document"))
.subscribe(fileAndContacts -> {
if (ringProgressDialog.isShowing()) { //debugger says
//dialog is showing.
ringProgressDialog.dismiss();
}
sendDocumentInEmail(fileAndContacts);
});
}
Run Code Online (Sandbox Code Playgroud)
任务正常执行。在我在同一个活动中执行另一个 RXJava 任务之前,我还显示了另一个环进度对话框,这个对话框出现了。
如果我注释掉 RxJava 调用,就会出现对话框。所以 RxJava 调用中的某些东西是阻塞的。
//EDIT 这个简单的 …
android ×10
progressdialog ×10
eclipse ×1
firebase ×1
firebaseui ×1
java ×1
listview ×1
rx-java ×1
typeface ×1