Android TableLayout wrap content - android

I have a LinearLayout with TableLayout and LinearLayout inside. TableLayout is made up of 5 TableRows. Each TableRow is made up of two View objects.
Firt column has two TextViews, my problem is that the text of TexView is wrapped:
The word SomeValue is wrapped, the letter e is a in new line, I'd like all in just one row, in this case and in general case, wath's the way pattern?
For example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="#dimen/padding_small"
android:id="#+id/layout1">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|top"
android:stretchColumns="0,true"
android:shrinkColumns="*,true">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Value1"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="#+id/spinnerPrefix"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
**<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SomeValue"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/valueU"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
<requestFocus />
</EditText>
</TableRow>**
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Mytext"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<EditText
android:id="#+id/valueN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AnyValue"
android:textAppearance="?android:attr/textAppearanceSmall" />
<DatePicker
android:id="#+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<RadioButton
android:id="#+id/radioM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="M" />
<RadioButton
android:id="#+id/radioF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="F" />
</RadioGroup>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="#dimen/padding_small" >
<Button
android:id="#+id/buttonRegistrazione"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Data" />
</LinearLayout>
</LinearLayout>

For each textview you could add
android:singleLine = "true"
That will make it a single line. If the text is too big then you could use ellipsize
android:ellipsize
to control how you want the text to appear

Related

Layout issue with ScrollView & table

I have a form using ScrollView. There are 2 spinners in the form and in portrait mode one of spinners goes out of the screen but in landscape view the spinner is visible. What setting needs to be changed so that spinner does not go out of the screen? (Comment- The label Select Month in the image should actually be "Select Month & Year" )
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20sp">
<!-- android:layout_width="wrap_content"
android:layout_height="match_parent"
-->
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/back"
android:scrollbars="vertical"
android:textSize="20sp">
<!--Month Combo Box-->
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Month & Year"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinneryr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#0c0b0b"
android:textSize="20sp" />
</TableRow>
<!--Field1 Combo Box-->
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ERYTHROCYTE"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/ERYTHROCYTE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field2 Combo Box-->
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/HAEMOGLOBIN"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/HAEMOGLOBIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field3 Combo Box-->
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/PCV"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/PCV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field4 Combo Box-->
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/RDW"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/RDW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field5 Combo Box-->
<TableRow
android:id="#+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCV"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field6 Combo Box-->
<TableRow
android:id="#+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCH"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCH"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field7 Combo Box-->
<TableRow
android:id="#+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCHC"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCHC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field8 Combo Box-->
<TableRow
android:id="#+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LEUCOCYTECOUNT"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/LEUCOCYTECOUNT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field9 Combo Box-->
<TableRow
android:id="#+id/tableRow10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/PLATELETS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/PLATELETS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field10 Combo Box-->
<TableRow
android:id="#+id/tableRow11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NEUTROPHILS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/NEUTROPHILS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field11 Combo Box-->
<TableRow
android:id="#+id/tableRow12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/EOSINOPHILS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/EOSINOPHILS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field12 Combo Box-->
<TableRow
android:id="#+id/tableRow13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LYMPHOCYTES"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/LYMPHOCYTES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!-- Button :Start here-->
<TableRow
android:id="#+id/tableRow14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20sp">
<Button
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/add" />
<Button
android:id="#+id/btnViewAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/view_all" />
</TableRow>
<!--<Button
android:id="#+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/delete" />
<Button
android:id="#+id/btnShowInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/show_info" />
</TableRow>-->
<!-- <TableRow
android:id="#+id/tableRow15"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20sp">
<Button
android:id="#+id/btnModify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/modify" />
<Button
android:id="#+id/btnView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/view" />
<Button
android:id="#+id/btnShowInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/show_info" >
</TableRow-->
<TextView
android:id="#+id/tvValues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="20sp" />
</TableLayout>
</ScrollView>
What setting needs to be changed so that spinner does not go out of the screen?
None. There's no settings for that - it's basically how you made your layout and it simply does not fit. You can consider having separate layout file for each orientation so you'd i.e. put spinners vertically for portrait layout -> just create layout-land in your res/ and copy current layout there. Then edit the one in layout to make it better fit the screen. That's it.
I am posting answer to my question. I managed to fix the issue by doing the following changes to ScrollView. After the change the TextView & both spinners are now visible on the same row and well aligned.
Code changes to ScrollView -
1) Updating android:layout_width="fill_parent"
2) Updating android:layout_height="fill_parent"
3) Adding android:fillViewport="true"
Code changes to TableLayout
1) Added android:layout_centerInParent="true"
2) Added android:gravity="center"
Solution suggested by #Marcin is another way (probably a more versatile solution) to solve the issue but since the above solution worked I did not try it.

Android: scroll part of screen horizontal and vertical

on the screen I need to populate some report type of data. I need to do horizontal and vertical scroll for part of the screen.
How to achieve this task...?
I try following code but it not work:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="**" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="Sl No."
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="4"
android:text="SubDivision"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="4"
android:text="Total No. of Works"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="Completed"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="In-progress"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="Award Cost(in Lakh)"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="Value of Work Done(in Lakh)"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="Payment Made(in Lakh)"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:text="Balance to be Paid(in Lakh)"
android:textColor="#color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="2"
android:text="% Paid"
android:textColor="#color/black" />
</TableRow>
</TableLayout>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
</HorizontalScrollView>
I had done something very similar, where i need to show excel sheet contents in listview that needs to be horizontally scroll-able.
I achieved this by putting listview inside horizontalScrollView.
something like below:
<HorizontalScrollView
// other attributes here.
>
<ListView
// listview attributes here
/>
</HorizontalScrollView>
You have to put it inside the scrollview like this
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="300dp"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="5dip">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tlGridTable" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<TextView
android:id="#+id/textView1"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/button1"
android:text="Column 2" />
<TextView
android:id="#+id/textView1"
android:text="Column 3"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/button1"
android:text="Column 4" />
<TextView
android:id="#+id/textView1"
android:text="Column 5"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="#+id/button1"
android:text="Column 6" />
</TableRow>
</TableLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
</HorizontalScrollView>

android design xml layout alignment (how to draw the like that)

How to design the following as shown in the picture:
my xml structure is:
<Root>
<other design>
<need to design as in picture>
</Root>
the picture is :
that is the text should appear in left and right alignment.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="HOUR"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$1.80"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="DAY"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$10.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="WEEK"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$35.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="MONTH"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$105.00"
android:textColor="#6686A8" />
</TableRow>
</TableLayout>
You can use TableLayout to achieve that kind of layout.

doesnt set text value in android

Im new in andorid.I put textview to set data from mymethods.But it goes force close.But I tried it in another activity page my code worked.So ı suspected my xml layout .does anyone take care of this problem ,if so I will be very gratefull.Thanks Here are my layout.xml and my codes:
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
Log.d("işkategorisi",iskate);
and Log.cat shows true value.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/backgrund" >
<!-- Header Starts -->
<LinearLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentTop="true"
android:background="#layout/header" >
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:background="#layout/footer" >
<ImageView
android:id="#+id/imagegeri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="220dp"
android:src="#drawable/geri" />
<ImageView
android:id="#+id/imagecikis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/cikis" />
</LinearLayout>
<TextView
android:id="#+id/textAD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/header"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:layout_marginRight="26dp"
android:text="Small Text"
android:textSize="13dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/footer"
android:layout_below="#id/textAD" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/header"
android:orientation="vertical"
android:padding="10dip" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="İş Kategorisi"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/txtiskate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rfyr"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aşama"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Görevli"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="#+id/Searchname"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</AutoCompleteTextView>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Öncelik"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<EditText
android:id="#+id/edituacikla"
android:layout_width="290dp"
android:layout_height="140dp"
android:ems="10"
android:inputType="textMultiLine" />
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gerçekleşen Süre"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<EditText
android:id="#+id/edittoplm"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView6"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/spinner4"
android:ems="10"/>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Saat"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tamamlanan(%)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<Button
android:id="#+id/btnvzgec"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="Vazgec" />
<Button
android:id="#+id/uwgncelle"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Güncelle" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
Initialize your Text View first
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
First you need to initialize your textview then after you can use it. Try below code.
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
'iskate' should be instance of a 'TextView' like iskate=(TextView)(TextView)findViewById(id of the layout in xml here);
in your case its a string how is this possible this will show compile time error.

Android: Image button is not alligned to right

I want my image button to be placed on the rt side bottom of the scree. but it is not getting visible.Please see the code.
<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"
tools:context=".MainActivity" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date of Birth:" />
<Button
android:id="#+id/dateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:text="Select date" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manual labour" />
<EditText
android:id="#+id/ed1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender :" />
<RadioGroup
android:id="#+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Occupation" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/occuaption_arrays"
android:prompt="#string/occupation_prompt" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Monthly Income" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/income_arrays"
android:prompt="#string/income_prompt" />
</TableRow>
</TableLayout>
<ImageButton
android:id="#+id/next"
android:layout_height="50dp"
android:layout_width="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:contentDescription="dfg"
android:src="#drawable/next"
android:visibility="visible"/>
I have tried using RelativeLayout as parent and add attribute android:layout_alignParentRight="true" and android:layout_alignParentBottom="true"
My image is very large.Is that can be a problem?
You have setted match-parent to width and height of TableLayout. So TableLayout overlaps ImageButton
use below code...
android:layout_width="match_parent"
android:layout_height="wrap-content"

Categories

Resources