Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setEnabled(),setClickable() not working

I have used FrameLayout in which I have used two LinearLayouts. The second one is initially invisible but when I press a button on layout one, the second layout becomes visible and overlaps the first layout. What I want is when my second layout appears the first layout's elements should not be clickable (or enabled). For this I have tried setEnabled(false) and setClickable(false) but both of these are not working I am not getting what is the problem.

Code is as follows

TableLayout table; 

EditText edit;  
ScrollView scroll;

Button btn_save;
Button btn_layer_save;
Button btn_cross;

AlertDialog alert_dialog;

LinearLayout layout_above;

int primary_selected;

RadioButton radio_geo;
RadioButton radio_alumni;

String geo = "no" ;
String alumni = "no" ;

int color;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    table = (TableLayout) findViewById(R.id.tableLayout1);
    edit = (EditText) findViewById(R.id.message_select_friends_edit_search);
    search_geo_name_list = new ArrayList<String>();
    search_id_list = new ArrayList<String>();

    scroll = (ScrollView) findViewById(R.id.register_scroll_view);

    btn_cross = (Button) findViewById(R.id.register_cross);
    btn_save = (Button) findViewById(R.id.register_save);
    btn_layer_save  = (Button) findViewById(R.id.register_layer_save);

    btn_cross.setOnClickListener(this);
    btn_save.setOnClickListener(this);
    btn_layer_save.setOnClickListener(this);

    layout_above = (LinearLayout) findViewById(R.id.regsiter_layout_layer_above);

    createTableRows(name_list,id_list);



}

void createTableRows(ArrayList<String> list_name , ArrayList<String> list_id )
{
    /*-----R O W S   O F   T A B L E   C R E A T E D   D Y N A M I C A L L Y ------*/
}

@Override
public void onClick(View v) 
{
    // TODO Auto-generated method stub

    switch (v.getId())
    {
    case R.id.register_save:

          layout_above.setVisibility(LinearLayout.VISIBLE);
          btn_save.setVisibility(LinearLayout.INVISIBLE);

        scroll.setEnabled(false);
        edit.setEnabled(false);
        edit.setClickable(false);
        scroll.setClickable(false);

        break;

    case R.id.register_cross:
        Toast.makeText(this, "Cross Cancel", 1000).show();
        Intent intent = new Intent(this, TestSave.class);
        startActivity(intent);
        finish();
        break;
    case R.id.register_layer_save:
        selectedInfo();
        break;

    } 

}`
like image 478
Arun Badole Avatar asked Jul 25 '11 07:07

Arun Badole


2 Answers

Take front layout's size as background layout's size and set front layout's background color transparent so background layout is partially
visible. And set onClickListener to front layout and in onClick method do nothing.

This answer is not exactly as you want but it is a good alternative.

Hope it helps

like image 148
shvivek Avatar answered Nov 15 '22 05:11

shvivek


Try using setFocusable(False); may be this should help you

like image 40
Abhinav Singh Maurya Avatar answered Nov 15 '22 04:11

Abhinav Singh Maurya