Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android RelativeLayout Eclipse上按钮的setvisibility存在问题_Android_Eclipse_Button - Fatal编程技术网

Android RelativeLayout Eclipse上按钮的setvisibility存在问题

Android RelativeLayout Eclipse上按钮的setvisibility存在问题,android,eclipse,button,Android,Eclipse,Button,嗨。。。。我正在做一个关于eclipse的简单项目。我正在使用相对布局,如下所示: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent

嗨。。。。我正在做一个关于eclipse的简单项目。我正在使用相对布局,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:gravity="center"   
    tools:context=".ProfileActivity" 
    >

<Button 
        android:id="@+id/Prof_edit_btn"
        android:layout_below="@+id/Prof_LL"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        android:text="Edit"
        android:layout_marginTop="17dp"
        android:layout_centerHorizontal="true"
        />

    <LinearLayout 
        android:layout_below="@+id/Prof_LL"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:orientation="horizontal"
        android:layout_centerHorizontal="true"

        >
    <Button 
        android:id="@+id/Prof_save_btn"
        android:layout_below="@+id/Prof_LL"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        android:text="save"
        android:layout_marginTop="17dp"
        android:layout_centerHorizontal="true"
        android:visibility="invisible"
        android:clickable="false"
        />
    <Button 
        android:id="@+id/Prof_batal_btn"            
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="Batal"
        android:layout_marginTop="17dp"            
        android:visibility="invisible"
        android:clickable="false"
        />
</LinearLayout>

</RelativeLayout>
mEdit = (Button)findViewById(R.id.Prof_edit_btn);
mEdit.setOnClickListener(new View.OnClickListener() {               
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub                  
                    mBatal.setVisibility(View.VISIBLE);
                    mBatal.setClickable(true);
                    mSave.setVisibility(View.VISIBLE);
                    mSave.setClickable(true);
                    mEdit.setVisibility(View.INVISIBLE);                    
            }
        });

mSave = (Button)findViewById(R.id.Prof_save_btn);
mSave.setOnClickListener(new View.OnClickListener() {               
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                mEdit.setVisibility(View.VISIBLE);  
                mBatal.setVisibility(View.INVISIBLE);
                mSave.setVisibility(View.INVISIBLE);
                Toast.makeText(getApplicationContext(), "Data Anda berhasil disimpan", Toast.LENGTH_SHORT).show();                  
            }
        });
嗯。。。正如我们可以从我的布局xml中看到的,只有编辑按钮在开始时可见,然后当用户根据编辑按钮的setonclick listener中的代码程序单击编辑时,保存和BATAL按钮将可见。一旦点击编辑按钮,它将不可见。。。。这里的问题是当我点击编辑按钮时,只有保存按钮可见,而BATAL按钮在点击保存按钮时可见,我现在面临的另一个问题是,当我点击编辑按钮时,编辑按钮根本不可见。。。。所以任何人都可以帮我解决这个问题(


提前感谢……

不……我找到了自己的解决方案……只需将SAVE btn和BATAL btn的可见性设置为GONE……一切都完成了……:-)


mBatal按钮查找ID在哪里?我还没有添加它…:-)但是该按钮将具有与mSave按钮几乎相同的clicklistener…:-)哦。。。是啊。。。我忘了取下那个…呵呵。。谢谢,海特…:-)
<Button 
            android:id="@+id/Prof_save_btn"
            android:layout_below="@+id/Prof_LL"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"            
            android:text="save"
            android:layout_marginTop="17dp"
            android:layout_centerHorizontal="true"
            android:visibility="gone"<-----------=
            android:clickable="false"
            />
        <Button 
            android:id="@+id/Prof_batal_btn"            
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:text="Batal"
            android:layout_marginTop="17dp"            
            android:visibility="gone"<-----------=
            android:clickable="false"
            />