布局和Toast不显示

时间:2017-10-18 21:13:46

标签: android android-layout layout visibility

我的MainActivity布局由4个嵌入式LinearLayout组成,所有这些都在XML中声明为Visibility:GONE。 第一个布局只包含TextView。我将此布局设置为VISIBLE,然后尝试在其中显示Toast。但是ToastTextView都没有显示 - 只是一个空白的屏幕。

同样的隐藏/取消隐藏技术在活动的其他区域有效,但我不明白为什么它不在这里。

对于Context的{​​{1}},我尝试过ToastthisMainActivity.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();

0 个答案:

没有答案