how to display all items in the listview - java

I'm trying to include a ListView on a screen that already exists in my app.
My problem is that the ListView is displaying only the first item. I wish it were
displayed all the list.
Here is the my screen's xml:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/radialback"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:orientation="vertical"
android:shrinkColumns="*">
<TableLayout
android:id="#id/tabela_cuerpo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0">
<TableRow
android:id="#id/tableRow0"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_cabecalho"
android:gravity="center_horizontal"
android:text="Corrida Recebida"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
</TableRow>
<TableRow
android:id="#id/tableRow1"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Cliente: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPassageiro"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow2"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Distância: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtDescricao"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow3"
android:layout_height="fill_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Endereço:"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtEndereco"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow4"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Valor: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtValor"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="R$ 0,00"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
<TableRow
android:id="#id/tableRow5"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text="Telefone: "
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"
android:textStyle="bold"/>
<TextView
android:id="#id/txtPtoReferencia"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="2.0"
android:autoLink="phone"
android:background="#drawable/tabela_conteudo"
android:paddingLeft="3.0dip"
android:text=""
android:textAppearance="?android:textAppearanceMedium"
android:textColor="#ff000000"/>
</TableRow>
</TableLayout>
<ListView
android:id="#+id/pedidos_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<Button
android:id="#id/btnAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_green"
android:text="Aceitar"/>
<Button
android:id="#id/btnVerMapa"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Mapa"/>
<Button
android:id="#id/btnVerOrigemWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Origem"/>
<Button
android:id="#id/btnVerDestinoWaze"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Ver Local Destino"/>
<Button
android:id="#id/btnInformarTmpEstimado"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Tempo Estimado"/>
<Button
android:id="#id/btnClienteBordo"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Produto Já Recolhido"/>
<Button
android:id="#id/btnInformarValor"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Informar Valor"/>
<Button
android:id="#id/btnRejeitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Rejeitar"/>
<Button
android:id="#id/btnCancelarAposAceitar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_red"
android:text="Cancelar Corrida"
android:visibility="invisible"/>
<Button
android:id="#id/btnFinalizar"
style="#style/ButtonText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_blue"
android:text="Finalizar Corrida"
android:visibility="invisible"/>
</LinearLayout>
</ScrollView>
The screen is getting as follows:
http://anstaxi.com.br/android-screen-current-wrong.png
I need all the items are displayed.
The code snippet is:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_corrida_multiponto);
String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.activity_listview_pedidos, mobileArray);
ListView listView = (ListView) findViewById(R.id.pedidos_list);
listView.setAdapter(adapter);
}
-

You problem is using a listview inside a scrollview. Listview cant streatch itself inside the scrollview.
And after solving this issue. You will have problem with th scrolling (which one to scroll?)
But this link solves your problem:
Android list view inside a scroll view

Related

How to make an own time table in android studio

I'm setting up my own time table and I have a lot of button on that I want to get multi-button I mean if someone wants to use the application. they can choose any time they want to have no limit. so how can I make a time table with those options?
here its XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="370dp"
android:layout_height="480dp"
android:background="#00555555"
android:orientation="vertical"
android:padding="5dp"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/round_layout_otp"
android:orientation="vertical"
android:padding="7dp"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="166dp"
android:layout_weight="60"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="80"
android:gravity="center">
<ImageView
android:id="#+id/a"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#fff"
android:gravity="center"
android:scaleType="fitCenter"
android:src="#drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20">
<TextView
android:id="#+id/txt_file_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:singleLine="true"
android:text="TEXTO"
android:textColor="#FFFFFF"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="457dp"
android:layout_weight="40"
android:background="#drawable/round_layout_white_otp"
android:orientation="vertical"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_weight="0">
<TextView
android:layout_width="match_parent"
android:layout_height="36dp"
android:gravity="center"
android:text="Chose Your Time :"
android:textColor="#ff000000"
android:textSize="15dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="769dp"
android:layout_gravity="center"
android:layout_weight="60">
<ScrollView android:id="#+id/layout"
android:layout_height="match_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="match_parent">
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="8:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt1" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt2" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt3" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="8:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt4" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt5" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt6" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="9:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt7" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="9:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt8" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt9" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt10" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt11" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="10:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt12" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="11:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt13" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="11:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt14" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="11:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt15" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:id="#+id/bt16" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:text="11:45" android:textSize="13sp" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt17" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt18" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="12:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt19" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="12:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt20" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt21" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt22" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt23" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="13:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt24" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="14:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt25" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt26" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt27" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="14:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt28" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt29" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt30" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="15:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt31" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="15:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt32" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/b33" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt34" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt35" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="16:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt36" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="17:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt37" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt38" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt39" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="17:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt40" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt41" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt42" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
<TableRow
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="75dp">
<Button android:layout_weight="1" android:text="18:30" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt43" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="18:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt44" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:00" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="13sp" android:id="#+id/bt45" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:15" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt46" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt47" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
<Button android:layout_weight="1" android:text="19:45" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textSize="13sp" android:id="#+id/bt48" android:background="#color/colorAccent" android:layout_marginLeft="1dp" android:layout_marginTop="1dp"/>
</TableRow>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_weight="40"
android:orientation="horizontal"
android:weightSum="0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="30dp"
android:layout_weight="50"
android:gravity="center|right">
<Button
android:id="#+id/btn_cancel"
android:layout_width="80dp"
android:layout_height="25dp"
android:background="#drawable/round_button"
android:gravity="center"
android:text="CANCEL"
android:textColor="#ffffffff"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="50"
android:gravity="center|left">
<Button
android:id="#+id/btn_okay"
android:layout_width="80dp"
android:layout_height="25dp"
android:background="#drawable/round_button"
android:text="OKAY"
android:textColor="#ffffffff"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
here activity code :
public class ViewDialog extends AppCompatActivity {
private int buttonState = 2;
ArrayList<String> al = new ArrayList<String>();
public void showDialog(Activity activity, String msg) {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.time_dialog);
dialog.getWindow().setBackgroundDrawable(new
ColorDrawable(android.graphics.Color.TRANSPARENT));
TextView text = (TextView) dialog.findViewById(R.id.txt_file_path);
text.setText(msg);
Button bt1 = (Button) dialog.findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(buttonState % 2 == 0){
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.btnclick));
al.add(bt1.getText().toString());
}
else{
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.colorAccent));
al.remove(bt1.getText().toString());
}
buttonState++;
}
});
Button dialogBtn_cancel = (Button)
dialog.findViewById(R.id.btn_cancel);
dialogBtn_cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//
Toast.makeText(getApplicationContext(),"Cancel" ,Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
Button dialogBtn_okay = (Button) dialog.findViewById(R.id.btn_okay);
dialogBtn_okay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(dialog.getContext(),al.get(0),Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
dialog.show();
}
}
public class ViewDialog extends AppCompatActivity {
private int buttonState = 2;
ArrayList<String> al = new ArrayList<String>();
public void showDialog(Activity activity, String msg) {
final Dialog dialog = new Dialog(activity);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(false);
dialog.setContentView(R.layout.time_dialog);
dialog.getWindow().setBackgroundDrawable(new
ColorDrawable(android.graphics.Color.TRANSPARENT));
TextView text = (TextView) dialog.findViewById(R.id.txt_file_path);
text.setText(msg);
Button bt1 = (Button) dialog.findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(buttonState % 1 == 0){
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.btnclick));
al.add(bt1.getText().toString());
}
else{
bt1.setBackgroundColor(dialog.getContext().getColor(R.color.colorAccent));
al.remove(bt1.getText().toString());
}
buttonState++;
}
});
Button dialogBtn_cancel = (Button)
dialog.findViewById(R.id.btn_cancel);
dialogBtn_cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//
Toast.makeText(getApplicationContext(),"Cancel" ,Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
});
Button dialogBtn_okay = (Button) dialog.findViewById(R.id.btn_okay);
dialogBtn_okay.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(dialog.getContext(),al.get(0),Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
dialog.show();
}
}
And also I need a variable for the selected time. please help me
Question 1: how to make a multi-button?
Question 2: how to make a variable for the selected time?

Why the buttons are not shown at the bottom of splitted layout?

Helo,
my code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1.0"
>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:padding="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3sp"
android:background="#color/colorAccent"
>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
>
<TextView
android:id="#+id/textView32"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/accounts"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10sp"
android:background="#color/colorAccent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_Account_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_description"
android:textStyle="bold"
android:paddingRight="10sp"
/>
<TextView
android:id="#+id/textView_Account_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold"
/>
</TableRow>
</TableLayout>
<!-- Scrollable Area 1 Begin -->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:layout_weight="1"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorAccent">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<!-- Scrollable Area 1 End -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent"
android:orientation="horizontal">
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto hinzufügen" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Konto löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center|bottom"
android:paddingBottom="10sp"
android:paddingLeft="20sp"
android:paddingRight="20sp"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/colorAccent2"
android:orientation="vertical"
android:gravity="center|bottom">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="3sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<TextView
android:id="#+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="#string/account_input_output"
android:textAllCaps="false"
android:textSize="18sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView_IO_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_date"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Nr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_description"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Ausgabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_ausgabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Eingabe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="10sp"
android:text="#string/account_io_eingabe"
android:textStyle="bold" />
<TextView
android:id="#+id/textView_IO_Sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/account_sum"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent2"
android:orientation="vertical">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10sp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorAccent2"
android:orientation="horizontal">
<Button
android:id="#+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion hinzufügen"
/>
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Transaktion löschen" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
My problem is:
The two buttons button6 and button7 below aren't displayed on screen. On android studio they are, but not on my mobile phone.
What am I doing wrong?
This is displayed in android studio gui builder
This is display on android emulator or real device
Hmm... I don't know if it's the best solution.
But I set the bottom padding of the second linear layout to:
20sp + 20 sp + black stripe on the bottom sp + 20 sp
Context context = rootView.getContext();
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
int width = resources.getDimensionPixelSize(resourceId);
LinearLayout l = (LinearLayout)rootView.findViewById(R.id.scrollView2);
float density = context.getResources().getDisplayMetrics().density;
int paddingDp = (int)(20 * density);
l.setPadding(paddingDp, 0, paddingDp, paddingDp + paddingDp + width);

Make table row scroll up and down in some period of time automatically

I have create a list of Currency exchange rate by using table with 6 row.
i want 6 row to have some animation like it running up and down automatically in some period of time so it can make user user more attractive on it.
please give me some example or if you have any idea to make table row animation that make more attractive for user.
Move the scrolled position of your view.
public void scrollBy (int x, int y)
Parameters
x - the amount of pixels to scroll by horizontally
y - the amount of pixels to scroll by vertically
lv.scrollBy(100,100) //....like this
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="0sp"
android:layout_weight="0.03"
android:background="#drawable/gradient">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/logo"
android:layout_marginLeft="50dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_marginTop="10dp"
android:text="GOLDEN ROYAL EXCHANGE"
android:textColor="#ba8707"
android:textStyle="bold"
android:textSize="16sp"
android:backgroundTintMode="multiply"
android:shadowColor="#030303"
android:phoneNumber="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="1sp"
android:background="#drawable/lineback"
android:layout_weight="0.62">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/myScrollview"
android:scrollbars="none">
<TableLayout
android:id="#+id/table01"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:background="#4042dba8"
android:id="#+id/khmerrow"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="3dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/khmerflages" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="-8dp"
android:text="Khmer Riel 柬币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="USD/KHR"
android:textColor="#000000"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="4,200"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/thaiflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-12dp"
android:layout_gravity="center"
android:text="Thai Baht 泰铢"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:text="USD/THB"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="35"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/chinaflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-3dp"
android:layout_gravity="center"
android:text="China RMB 人民币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="18dp"
android:text="USD/RMB"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="6.7"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/hongkongflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="9dp"
android:layout_gravity="center"
android:text="HongKong Dollar 港币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:text="USD/HKD"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="8.7"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/malaysiaflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_gravity="center"
android:text="Malaysia MYR 马币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:text="USD/MYR"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="6.6"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TableRow android:background="#4042dba8"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:minHeight="145px"
android:layout_marginTop="2.5sp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:src="#drawable/singaporeflags" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_gravity="center"
android:text="Singapore SGD 新币"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:text="USD/SGD"
android:textColor="#000000"
android:textSize="12sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="30dp"
android:text="1.6"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</TableRow>
<TextView
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_marginTop="2.5sp"
android:textColor="#000000"
android:id="#+id/date" />
</TableLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="1sp"
android:background="#dee6d461"
android:layout_weight="0.36">
<ViewFlipper
android:id="#+id/bckgrndViewFlipper1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="#+id/bckgrndImageView8"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange1" />
<ImageView
android:id="#+id/bckgrndImageView7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange2" />
<ImageView
android:id="#+id/bckgrndImageView6"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange3" />
<ImageView
android:id="#+id/bckgrndImageView5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange4" />
<ImageView
android:id="#+id/bckgrndImageView4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange5" />
<ImageView
android:id="#+id/bckgrndImageView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/exchange6" />
</ViewFlipper>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="25dp"
android:background="#drawable/gradient">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/trading"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Trading Hours .................`enter code here`"
android:textSize="13sp"
android:textColor="#ba8707"/>
</LinearLayout>
</LinearLayout>
public class MainActivity extends AppCompatActivity {
Animation fade_in, fade_out, rowanimation;
ViewFlipper viewFlipper;
ScrollView myView;
TextView date;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewFlipper = (ViewFlipper) this.findViewById(R.id.bckgrndViewFlipper1);
fade_in = AnimationUtils.loadAnimation(this,
android.R.anim.fade_in);
fade_out = AnimationUtils.loadAnimation(this,
android.R.anim.fade_out);
viewFlipper.setInAnimation(fade_in);
viewFlipper.setOutAnimation(fade_out);
viewFlipper.setAutoStart(true);
viewFlipper.setFlipInterval(5000);
viewFlipper.startFlipping();
}
}

Android: onClick event listener doesn't work on linearlayout

I am trying to implement an onclick for the entire layout but it won't work.
Here is my function for my RelativeLayout:
public void updateRange(View v)
{
System.out.println("Hello!");
}
and here is my xml:
<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="wrap_content"
tools:context=".MainActivity"
android:background="#ffffffff"
android:id="#+id/xasdf"
android:onClick="updateRange">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/toptab"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Settings"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/settingsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solutions"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/solutionsButton"
android:background="#fffdb64b" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mode"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.333333"
android:id="#+id/modeButton"
android:background="#fffdb64b" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/chartlayout"
android:layout_below="#+id/toptab"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:weightSum="1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<EditText
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/textView"
android:layout_weight="0.5"
android:background="#ffffffff"
android:fontFamily="monospace"
android:hint="y = ..." />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Graph"
android:fontFamily="monospace"
android:textAllCaps="false"
android:layout_weight="0.25"
android:id="#+id/button"
android:background="#ffd0d0d0"
android:onClick="drawGraph" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Table"
android:fontFamily="monospace"
android:layout_weight="0.25"
android:textAllCaps="false"
android:id="#+id/button2"
android:background="#ffd0d0d0" />
</LinearLayout>
</RelativeLayout>
Try adding the extra line below to your Relative Layout description:
...
android:onClick="updateRange"
android:clickable="true">

Q: SlidingDrawer is Not Scrolling Up

My SlidingDrawer is working but not Scrolling Up enough. Handle when come to bottom of the "MENÜYE DÖN" button, stopping! I can't scroll more. I know SlidingDrawer is deprecated but I do not know the alternative.
I can see in Preview, SlidingDrawer's border is narrow.
Here is XML
<?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"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:padding="30dp"
android:textSize="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1. Sözlük hazırlamanın en güç yanı sözcükleri anlam kayganlığından kurtarma, onları belli bir yere oturtmadır. Bu da ancak Samuel Butler’in dediği gibi onların belirsiz yanlarını söz duvarlarıyla kuşatmakla gerçekleşebilir.
Bu cümledeki altı çizili sözle, sözcüklere yönelik olarak ne yapıldığı anlatılmıştır?"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL0">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="A) Tanımsal sınırlar koyulduğu"
android:id="#+id/a" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/LL2"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL1">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="B) Birbirlerinden etkilenişlerinin gösterildiği"
android:id="#+id/b"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL3">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="C) Çağrışımsal değerlerinin belirtildiği"
android:id="#+id/c"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL4">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="D) Zenginleştirme yollarının açıklandığı"
android:id="#+id/d"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL5">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="E) Kullanım sıklığının yansıtıldığı"
android:background="#drawable/flat_button"
android:id="#+id/e"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="20dp">
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="Menüye Dön"
android:background="#bababa"
android:id="#+id/anamenudon"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SlidingDrawer
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:content="#+id/content"
android:handle="#+id/handle"
android:id="#+id/slidingDrawer"
android:layout_gravity="center_horizontal">
<Button
android:id="#+id/handle"
android:layout_width="200dp"
android:layout_height="33dp"
android:text="== ÇÖZÜM =="
android:textSize="10dp"/>
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ababab">
<TextView
android:paddingTop="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CEVAP BURADA"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</LinearLayout>
I Found! It works perfectly.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:id="#+id/scrollLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:padding="30dp"
android:textSize="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1. Sözlük hazırlamanın en güç yanı sözcükleri anlam kayganlığından kurtarma, onları belli bir yere oturtmadır. Bu da ancak Samuel Butler’in dediği gibi onların belirsiz yanlarını söz duvarlarıyla kuşatmakla gerçekleşebilir.
Bu cümledeki altı çizili sözle, sözcüklere yönelik olarak ne yapıldığı anlatılmıştır?"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="10dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL0">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="A) Tanımsal sınırlar koyulduğu"
android:id="#+id/a" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/LL2"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_below="#+id/LL1">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="B) Birbirlerinden etkilenişlerinin gösterildiği"
android:id="#+id/b"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL3">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="C) Çağrışımsal değerlerinin belirtildiği"
android:id="#+id/c"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL4">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/flat_button"
android:text="D) Zenginleştirme yollarının açıklandığı"
android:id="#+id/d"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="7dp"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:id="#+id/LL5">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="E) Kullanım sıklığının yansıtıldığı"
android:background="#drawable/flat_button"
android:id="#+id/e"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="20dp">
<Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:text="Menüye Dön"
android:background="#bababa"
android:id="#+id/anamenudon"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<SlidingDrawer
android:layout_width="wrap_content"
android:layout_height="250dp"
android:content="#+id/content"
android:handle="#+id/handle"
android:id="#+id/slidingDrawer"
android:layout_gravity="center_horizontal"
android:padding="10dip">
<Button
android:id="#+id/handle"
android:layout_width="200dp"
android:layout_height="33dp"
android:text="== ÇÖZÜM =="
android:textSize="10dp"/>
<LinearLayout
android:id="#+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ababab"
android:gravity="center|top"
android:padding="10dip">
<TextView
android:paddingTop="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="CEVAP BURADA"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</RelativeLayout>

Categories

Resources