我的MainActivity
布局由4个嵌入式LinearLayout
组成,所有这些都在XML中声明为Visibility:GONE
。
第一个布局只包含TextView
。我将此布局设置为VISIBLE
,然后尝试在其中显示Toast。但是Toast
和TextView
都没有显示 - 只是一个空白的屏幕。
同样的隐藏/取消隐藏技术在活动的其他区域有效,但我不明白为什么它不在这里。
对于Context
的{{1}},我尝试过Toast
,this
和MainActivity.this
。什么都行不通。 (该程序有效,它只是不显示TextView或Toast)
[代码]
getApplicationContext()
...
@BindView(R.id.layout_configuration) LinearLayout linearLayoutConfiguration;
@BindView(R.id.layout_appupdater) LinearLayout linearLayoutAppUpdater; //Added to handle app-updating clause
@BindView(R.id.layout_user) RelativeLayout linearLayoutUser;
@BindView(R.id.layout_capture) LinearLayout linearCapture;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // contains the above 4 layouts, all initialized to GONE visibility
ButterKnife.bind(this);
BusProvider.getInstance().register(this);
init(); // unrelated to display
}
...
if (versionMismatch) {
setDisplayAppUpdating();
Log.d(TAG, "Trying to update app...");
//(doesn't print) if we've detected a newer version in the cloud, get it.
Toast.makeText(MainActivity.this, "Updating app...", Toast.LENGTH_SHORT).show();
apkDownloadInteractor = new DownloadApkInteractor (
ThreadExecutor.getInstance(),
MainThread.getInstance(),
Patient.getInstance());
apkDownloadInteractor.execute();