Android 加载时隐藏活动,直到加载所有内容

Android 加载时隐藏活动,直到加载所有内容,android,android-activity,Android,Android Activity,我想知道在加载内容之前是否可以隐藏和活动及其相关组件。例如,我将一个图像从url检索到imageview中,在图像显示之前总是有一个延迟。我想在淡出整个活动的情况下对用户隐藏它,例如只显示一个进度条 有人能在这个话题上给我指点一下吗 谢谢 我将布局中的可见性设置为不可见,如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"

我想知道在加载内容之前是否可以隐藏和活动及其相关组件。例如,我将一个图像从url检索到imageview中,在图像显示之前总是有一个延迟。我想在淡出整个活动的情况下对用户隐藏它,例如只显示一个进度条

有人能在这个话题上给我指点一下吗

谢谢

我将布局中的可见性设置为不可见,如下所示:

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="invisible" >
...
 </RelativeLayout>
AsynchTask完成后,我尝试将可见性设置为visible,但布局仍然不可见:

@Override
        protected void onPostExecute(JSONObject json) {
            /**
             * Checks for success message.
             **/
            try {
                if (json.getString(KEY_SUCCESS) != null) {

                    String res = json.getString(KEY_SUCCESS);

                    String red = json.getString(KEY_ERROR);

                    if (Integer.parseInt(res) == 1) {

                        JSONObject json_user = json.getJSONObject("user");

                        image_url = json_user.getString(KEY_AVATAR_PATH);

                        // ImageLoader class instance
                        ImageLoader imgLoader = new ImageLoader(getActivity());

                        imgLoader.DisplayImage(image_url, image_);


                        profile_view.setVisibility(View.VISIBLE);
}

您可以放置全屏视图,在加载时显示,加载后隐藏。

在活动xml的主布局上设置可见性=不可见。一切就绪后,按程序进行设置。我编辑我的问题。我用目前的努力编写了代码,但仍然没有进展。为什么不使用一个启动屏幕片段(可以有一个进度条),然后在异步任务完成后将其替换掉呢?尝试在onCreateView上设置profile_view.setVisibility(view.INVISIBLE)。并删除xml android:Visibility是否确定此语句已到达并执行profile view.setVisibility(view.VISIBLE)?因为之前有一些条件,如果其中一个条件失败了怎么办?你处理过那种情况吗?
@Override
        protected void onPostExecute(JSONObject json) {
            /**
             * Checks for success message.
             **/
            try {
                if (json.getString(KEY_SUCCESS) != null) {

                    String res = json.getString(KEY_SUCCESS);

                    String red = json.getString(KEY_ERROR);

                    if (Integer.parseInt(res) == 1) {

                        JSONObject json_user = json.getJSONObject("user");

                        image_url = json_user.getString(KEY_AVATAR_PATH);

                        // ImageLoader class instance
                        ImageLoader imgLoader = new ImageLoader(getActivity());

                        imgLoader.DisplayImage(image_url, image_);


                        profile_view.setVisibility(View.VISIBLE);
}