0

I want to create a medical app. So after the person selects the option 'left eye' the test should start. It should show the result. At the end of test result, the option for testing the other eye should be shown. At that time the 'Left eye' button option should be disabled. This should be true vice-versa also i.e if the person selects 'Right eye', then after testing, the right eye option should be disabled. I am attaching the code.

public void resetView(){

    setContentView(R.layout.duochrometest);
    setObjects();
    int a[] = { R.id.leftEye, R.id.rightEye };
    setOnClickListener(a);
}

@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.leftEye:
        case R.id.rightEye:
            resetTestView();
            break;                          
        case R.id.testagain:
            ++testCount;
            resetView();
            break;
        case R.id.backtoTests:
            backToTests();
            break;
        default:
            calculateResult((String) v.getTag());
            changeObject();
    }
}

xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    android:orientation="vertical"
    android:background="@drawable/bg">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:padding="8dp"
        android:gravity="top"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/duochromeDesc"
        android:textColor="@color/white"/>

        <LinearLayout  
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:padding="2dp"
        android:orientation="horizontal">

        <Button android:id="@+id/leftEye" android:text="@string/lefteye"   android:textColor="@color/white" android:layout_width="150dp"  android:layout_height="wrap_content" android:background="@drawable/borderlightgray"></Button>

        <Button android:id="@+id/rightEye" android:text="@string/righteye" android:textColor="@color/white" android:layout_width="150dp" android:layout_height="wrap_content" android:background="@drawable/borderlightgray"></Button>

        </LinearLayout>
</LinearLayout>

Please help me on it.

jww
  • 97,681
  • 90
  • 411
  • 885
Amdoc
  • 23
  • 1
  • 5

2 Answers2

1

You can call setEnabled(false) on your button.

Tim Malseed
  • 6,003
  • 6
  • 48
  • 66
0

use this inside of the button in the layout file. android:visibility="gone" and use this tag inside the activity where you want to show the button Button.setVisibility(View.VISIBLE); Use these two flage effectively "gone" and "visible" you may can can got the answer. #Ravindra