猿问

各位大虾,紧急求助

申明了一个属性:private View mPassView;


为什么我在handlePassEvent()方法中通过mPassView属性调用anser_right布局不会生效?

private void handlePassEvent() {

mPassView = (LinearLayout)this.findViewById(R.id.pass_view);

mPassView.setVisibility(View.VISIBLE);

这里的调用不会出现通关界面,其它是正常的,求解



xml布局应该是没有错误的

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/pass_view"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:background="#cc000000"

    android:gravity="center"

    android:orientation="vertical" 

    android:visibility="gone" >


    <LinearLayout

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:gravity="center" >


        <ImageView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginRight="5dp"

            android:src="@drawable/index_medal" />


        <TextView

            android:id="@+id/text_main_achievement"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="您已击败"

            android:textColor="@color/white"

            android:textSize="18sp" />

    </LinearLayout>


    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginTop="40dp"

        android:text="答案正确"

        android:textColor="@color/white"

        android:textSize="35sp" />


    <FrameLayout

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginBottom="40dp"

        android:layout_marginTop="40dp" >


        <ImageView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:src="@drawable/game_level_title" />


        <TextView

            android:id="@+id/text_current_stage_pass"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_gravity="center"

            android:text="1"

            android:textColor="@color/white"

            android:textSize="20sp"

            android:textStyle="bold" />

    </FrameLayout>


    <TextView

        android:id="@+id/text_current_song_name_pass"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginBottom="20dp"

        android:text="同桌的你"

        android:textColor="@color/white"

        android:textSize="20sp" />


    <LinearLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginBottom="20dp"

        android:gravity="center" >


        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="奖励:"

            android:textColor="@color/white"

            android:textSize="20sp" />


        <ImageView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:src="@drawable/game_coin_icon" />


        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="*"

            android:textColor="@color/white"

            android:textSize="25sp" />


        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="3"

            android:textColor="@color/white"

            android:textSize="25sp" />

    </LinearLayout>


    <ImageButton

        android:id="@+id/btn_next"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginBottom="20dp"

        android:background="@drawable/next_button_icon" />


    <ImageButton

        android:id="@+id/btn_share"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:background="@drawable/weixin_button_icon" />


</LinearLayout>


andriod_2014
浏览 1779回答 2
2回答

andriod_2014

已经解决,我在主界面中引用这个布局时,位置出现了错误,谢谢

溜达溜达

检查一下,在主界面中是否已经引用了这个布局
随时随地看视频慕课网APP

相关分类

Android
我要回答