0
The question is this... I have a Vertical Scrollview with 20 buttons positioned in 5x2 view, when I use the scroll I see the other 10 buttons that are hidden, but these buttons are invisible if I do not have functions defined in the select of the bank that I use to popular the buttons... Here comes the big problem, scrollView still scrolls to the last button even if it is invisible, has some way of not letting scroll beyond the buttons q are visible?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.dev_03.sabbemobile.Telas.Pedidos.BarRestaurante.FastFood.FastFoodPedidos.FastFoodPedidoActivity$PlaceholderFragment">
<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/scrTabRef1"
android:layout_centerHorizontal="true"
android:layout_marginTop="19dp"
android:text="Sobremesas"
android:textAllCaps="true"
android:textColor="@android:color/background_dark"
android:textStyle="bold" />
<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Bebidas"
android:textAllCaps="true"
android:textColor="@android:color/background_dark"
android:textStyle="bold" />
<ScrollView
android:id="@+id/scrTabRef1"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_centerHorizontal="true"
android:layout_below="@+id/textView17">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnTabRfrRfr1"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr2"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrRfr1"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr3"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrRfr2"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr4"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrRfr3"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr5"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrRfr4"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr6"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrRfr1"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr7"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr2"
android:layout_toRightOf="@+id/btnTabRfrRfr6"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr8"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr3"
android:layout_toRightOf="@+id/btnTabRfrRfr7"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr9"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr4"
android:layout_toRightOf="@+id/btnTabRfrRfr8"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr10"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr5"
android:layout_toRightOf="@+id/btnTabRfrRfr9"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr11"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrRfr6"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr12"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr7"
android:layout_toRightOf="@+id/btnTabRfrRfr11"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr13"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr8"
android:layout_toRightOf="@+id/btnTabRfrRfr12"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr14"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr9"
android:layout_toRightOf="@+id/btnTabRfrRfr13"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr15"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr10"
android:layout_toRightOf="@+id/btnTabRfrRfr14"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr16"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrRfr11"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr17"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr12"
android:layout_toRightOf="@+id/btnTabRfrRfr16"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr18"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr13"
android:layout_toRightOf="@+id/btnTabRfrRfr17"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr19"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr14"
android:layout_toRightOf="@+id/btnTabRfrRfr18"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrRfr20"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrRfr15"
android:layout_toRightOf="@+id/btnTabRfrRfr19"
android:background="@drawable/button_pressed"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
</RelativeLayout>
</ScrollView>
<ScrollView
android:id="@+id/scrTabRef2"
android:layout_width="wrap_content"
android:layout_height="130dp"
android:layout_below="@+id/textView18"
android:layout_centerHorizontal="true"
android:layout_marginTop="9dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/btnTabRfrSbm1"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm2"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrSbm1"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm3"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrSbm2"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm4"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrSbm3"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm5"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/btnTabRfrSbm4"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm6"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrSbm1"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm7"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm2"
android:layout_toRightOf="@+id/btnTabRfrSbm6"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm8"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm3"
android:layout_toRightOf="@+id/btnTabRfrSbm7"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm9"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm4"
android:layout_toRightOf="@+id/btnTabRfrSbm8"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm10"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm5"
android:layout_toRightOf="@+id/btnTabRfrSbm9"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm11"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrSbm6"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm12"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm7"
android:layout_toRightOf="@+id/btnTabRfrSbm11"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm13"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm8"
android:layout_toRightOf="@+id/btnTabRfrSbm12"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm14"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm9"
android:layout_toRightOf="@+id/btnTabRfrSbm13"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm15"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm10"
android:layout_toRightOf="@+id/btnTabRfrSbm14"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm16"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/btnTabRfrSbm11"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm17"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm12"
android:layout_toRightOf="@+id/btnTabRfrSbm16"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm18"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm13"
android:layout_toRightOf="@+id/btnTabRfrSbm17"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm19"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm14"
android:layout_toRightOf="@+id/btnTabRfrSbm18"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrSbm20"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_below="@+id/btnTabRfrSbm15"
android:layout_toRightOf="@+id/btnTabRfrSbm19"
android:background="@drawable/button_pressed_green"
android:text="Button"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
</RelativeLayout>
</ScrollView>
<Button
android:id="@+id/btnTabRfrFinalizar"
android:layout_width="95dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="@drawable/button_pressed"
android:text="Finalizar Pedido"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
<Button
android:id="@+id/btnTabRfrVoltar"
android:layout_width="95dp"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="@drawable/button_pressed"
android:text="Voltar"
android:textColor="@android:color/background_light"
android:textSize="12sp" />
//TODO DECLARAÇÃO DOS BOTÕES REFRI
btnRefri[0] = rootView.findViewById(R.id.btnTabRfrRfr1);
btnRefri[1] = rootView.findViewById(R.id.btnTabRfrRfr2);
btnRefri[2] = rootView.findViewById(R.id.btnTabRfrRfr3);
btnRefri[3] = rootView.findViewById(R.id.btnTabRfrRfr4);
btnRefri[4] = rootView.findViewById(R.id.btnTabRfrRfr5);
btnRefri[5] = rootView.findViewById(R.id.btnTabRfrRfr6);
btnRefri[6] = rootView.findViewById(R.id.btnTabRfrRfr7);
btnRefri[7] = rootView.findViewById(R.id.btnTabRfrRfr8);
btnRefri[8] = rootView.findViewById(R.id.btnTabRfrRfr9);
btnRefri[9] = rootView.findViewById(R.id.btnTabRfrRfr10);
btnRefri[10] = rootView.findViewById(R.id.btnTabRfrRfr11);
btnRefri[11] = rootView.findViewById(R.id.btnTabRfrRfr12);
btnRefri[12] = rootView.findViewById(R.id.btnTabRfrRfr13);
btnRefri[13] = rootView.findViewById(R.id.btnTabRfrRfr14);
btnRefri[14] = rootView.findViewById(R.id.btnTabRfrRfr15);
btnRefri[15] = rootView.findViewById(R.id.btnTabRfrRfr16);
btnRefri[16] = rootView.findViewById(R.id.btnTabRfrRfr17);
btnRefri[17] = rootView.findViewById(R.id.btnTabRfrRfr18);
btnRefri[18] = rootView.findViewById(R.id.btnTabRfrRfr19);
btnRefri[19] = rootView.findViewById(R.id.btnTabRfrRfr20);
btnRefri[0].setVisibility(View.INVISIBLE);
btnRefri[1].setVisibility(View.INVISIBLE);
btnRefri[2].setVisibility(View.INVISIBLE);
btnRefri[3].setVisibility(View.INVISIBLE);
btnRefri[4].setVisibility(View.INVISIBLE);
btnRefri[5].setVisibility(View.INVISIBLE);
btnRefri[6].setVisibility(View.INVISIBLE);
btnRefri[7].setVisibility(View.INVISIBLE);
btnRefri[8].setVisibility(View.INVISIBLE);
btnRefri[9].setVisibility(View.INVISIBLE);
btnRefri[10].setVisibility(View.INVISIBLE);
btnRefri[11].setVisibility(View.INVISIBLE);
btnRefri[12].setVisibility(View.INVISIBLE);
btnRefri[13].setVisibility(View.INVISIBLE);
btnRefri[14].setVisibility(View.INVISIBLE);
btnRefri[15].setVisibility(View.INVISIBLE);
btnRefri[16].setVisibility(View.INVISIBLE);
btnRefri[17].setVisibility(View.INVISIBLE);
btnRefri[18].setVisibility(View.INVISIBLE);
btnRefri[19].setVisibility(View.INVISIBLE);
btnRefri[0].setClickable(false);
btnRefri[1].setClickable(false);
btnRefri[2].setClickable(false);
btnRefri[3].setClickable(false);
btnRefri[4].setClickable(false);
btnRefri[5].setClickable(false);
btnRefri[6].setClickable(false);
btnRefri[7].setClickable(false);
btnRefri[8].setClickable(false);
btnRefri[9].setClickable(false);
btnRefri[10].setClickable(false);
btnRefri[11].setClickable(false);
btnRefri[12].setClickable(false);
btnRefri[13].setClickable(false);
btnRefri[14].setClickable(false);
btnRefri[15].setClickable(false);
btnRefri[16].setClickable(false);
btnRefri[17].setClickable(false);
btnRefri[18].setClickable(false);
btnRefri[19].setClickable(
PopulaBtnRefri();
PopulaBtnSobreMesa();
return rootView;
}
public void PopulaBtnRefri() {
try {
gpConn = new GruposProd(getContext());
Cursor cursor;
db = gpConn.getReadableDatabase();
cursor = db.rawQuery("SELECT DISTINCT DESCRICAO_RESUMIDA, CODINTERNOPRODUTO, CODGRUPO FROM PRODUTO_FINAL " +
"INNER JOIN PRODUTO_ACOMP ON PRODUTO_ACOMP.BEBIDA = 'S' WHERE CODINTERNOPRODUTO = PRODUTO_ACOMP.CODACOMP", null);
int i = 0;
if(cursor.getCount() > 0) {
cursor.moveToFirst();
do{
refri[i] = cursor.getString(cursor.getColumnIndex("DESCRICAO_RESUMIDA"));
btnRefri[i].setText(refri[i]);
btnRefri[i].setVisibility(View.VISIBLE);
btnRefri[i].setTextColor(Color.parseColor("#FFFFFF"));
btnRefri[i].setTextSize(12);
btnRefri[i].setClickable(true);
i++;
}while(cursor.moveToNext());
}
db.close();
} catch (Exception e) {
Log.e("btnRefri", "erro", e);
}
}
}
Where’s the master code?!
– viana
I don’t know how to post it formatted here =(
– Marcio Vieira
Okay, part of the code is there, at least what’s important
– Marcio Vieira