RelativeLayout Eclipse上按钮的可设置性问题

时间:2015-07-08 06:55:51

标签: android eclipse button

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

` Questions = new ArrayList<String>();
    q1 = "I value learning and knowledge.  I am self- reliant and expect the same of others.";
    Questions.add(q1);
    q2 = "I am vitally interested in the development of my own potentials and open to learning. I respect the needs and values of others and I am willing to give help and contribute";
    Questions.add(q2);
    q3 = "I am excited by the challenge of experimentation and discovery. I believe that the pursuit of knowledge for its own sake is important.";
  Questions.add(q3);
    q4 = "I tend to be an observer in most situations. I give a lot of space to others and do not interfere unless invited to join in.";
 Questions.add(q4);
    q5 = "I tend to be a loner, and enjoy a deep conversation with people who show a genuine interest in things I am interested in.";
Questions.add(q5);
    q6 = "I value high quality work done with care that goes into creating products and services of intrinsic worth. I dislike acting in a hasty and haphazard manner.";
    Questions.add(q6);
    q7 = "I have concerns and doubts about how I am received by others. I tend to withhold my doubts and concerns and get withdrawn when I am troubled.";
   Questions.add(q7);
    q8 = "I am a proficient knowledge creator; I like to get immersed in study and research leading to acquisition of skills and knowledge.";
    Questions.add(q8);

在主要活动中,我为编辑和保存按钮创建了一个简单的onClicklistener,如下所示:

<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>

嗯......正如我们从布局xml中看到的那样,只有EDIT按钮在开始时可见,然后当用户根据EDIT的setonclick监听器中的代码程序点击EDIT时,SAVE和BATAL按钮将可见按钮。一旦单击EDIT按钮,它将是不可见的....这里的问题是当我点击EDIT按钮时,只有SAVE按钮可见,当点击SAVE按钮时BATAL按钮可见,另一个问题我是现在面对的是EDIT按钮在我点击它时根本不可见....所以..任何人都可以帮我解决这个问题... ??? :'(

提前致谢....

1 个答案:

答案 0 :(得分:0)

Naaah ......我找到了自己的解决方案......只需将SAVE btn和BATAL btn的可见性设置为GONE ......并且全部完成......: - )

if(window.location.href.indexOf("buying-a-car") > -1) {
 alert("your url contains the name buying a car");
}