之间有什么准确的区别appbar,Toolbar,Actionbar?什么时候专门使用它们?我试着找到它们,但它让我感到困惑,所以任何好友都可以向我解释它们之间的确切区别以及何时使用它们或者这是单个组件的同名吗?
android android-actionbar android-toolbar android-appbarlayout
我正在使用Firebase将数据显示到textview中。我使用asynctask在后台加载数据,而在加载时,我想在数据加载到textview中之前显示一条加载消息。
但是我的加载数据弹出窗口没有显示。(即doinBackground方法完成后,它可以立即工作),并且用户仅在Firebase数据加载之后才能看到空的文本视图。
如何防止这种情况并显示进程对话框,直到我的textview加载Firebase数据?
here is my code
<pre>
<code>
public class LastPage extends AppCompatActivity {
TextView title, author, article;
DatabaseReference mDatabase;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_last_page);
title = (TextView) findViewById(R.id.last_page_title);
author = (TextView) findViewById(R.id.last_page_author);
article = (TextView) findViewById(R.id.last_page_article);
mDatabase = FirebaseDatabase.getInstance().getReference();
new LoadFirebaseData().execute();
}
private class LoadFirebaseData extends AsyncTask<Void, Void, Integer>
{
private ProgressDialog Dialog = new ProgressDialog(LastPage.this);
@Override
protected void onPreExecute()
{
try {
Dialog.setMessage("Doing something...");
Dialog.show();
}catch (Exception e)
{ …Run Code Online (Sandbox Code Playgroud) 大家好,我有 2 个这样的 Toast 版本
版本 1:
Toast.makeText(getApplicationContext(),"hello",Toast.LENGTH_LONG).setGravity(Gravity.CENTER,0,0).show();
Run Code Online (Sandbox Code Playgroud)
版本 2:
Toast t = Toast.makeText(getApplicationContext(),"hello",Toast.LENGTH_LONG);
t.setGravity(Gravity.CENTER,0,0);
t.show();
Run Code Online (Sandbox Code Playgroud)
版本 2 工作正常,但版本 1 不行。它给出了错误无法解决方法 show()。这里出了什么问题?
当我编写版本 1 删除 setGravity() 方法时,它工作正常
Toast.makeText(getApplicationContext(),"hello",Toast.LENGTH_LONG).show();
Run Code Online (Sandbox Code Playgroud)
你们能解释一下吗。