Making table row scrollable in Java in Android Stud - java

I tried creating a scroll view in my relative layout to make my table layout scrollable but i keep getting this error:
02-02 19:29:10.116: E/AndroidRuntime(9400):
java.lang.RuntimeException: Unable to start activity ComponentInfo{test.com.classmanagertest/test.com.classmanagertest.StudentsMasterList}: java.lang.IllegalStateException:
The specified child already has a parent. You must call removeView() on the child's parent first.
This is my Table Layout that display's fields in a database:
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.students_masterlist);
db=openOrCreateDatabase("ClassManager",MODE_WORLD_WRITEABLE, null);
Cursor c=db.rawQuery("SELECT StudPic, StudentID, LastName FROM MasterStudents", null);
int count= c.getCount();
c.moveToFirst();
TableLayout tableLayout = new TableLayout(getApplicationContext());
tableLayout.setVerticalScrollBarEnabled(true);
TableRow tableRow;
TextView textView, textView1;
ImageView StudImageView;
RelativeLayout rl=(RelativeLayout)findViewById(R.id.layout);
ScrollView sv = new ScrollView(this);
sv.addView(tableLayout);
rl.addView(sv);
for (Integer j = 0; j < count; j++)
{
tableRow = new TableRow(getApplicationContext());
StudImageView = new ImageView(getApplicationContext());
StudImageView.setPadding(20, 20, 20, 20);
StudImage=c.getBlob(c.getColumnIndex("StudPic"));
Bitmap b1= BitmapFactory.decodeByteArray(StudImage, 0, StudImage.length);
StudImageView.setImageBitmap(b1);
tableRow.addView(StudImageView);
textView1 = new TextView(getApplicationContext());
textView1.setText(c.getString(c.getColumnIndex("StudentID")));
textView1.setPadding(20, 20, 20, 20);
textView1.setTextColor(getResources().getColor(R.color.blueactionbar));
textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP,25);
textView1.setTypeface(null, Typeface.BOLD);
tableRow.addView(textView1);
textView = new TextView(getApplicationContext());
textView.setText(c.getString(c.getColumnIndex("LastName")));
textView.setPadding(20, 20, 20, 20);
textView.setTextColor(getResources().getColor(R.color.blueactionbar));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP,25);
textView.setTypeface(null, Typeface.BOLD);
tableRow.addView(textView);
tableLayout.addView(tableRow);
c.moveToNext() ;
}
setContentView(tableLayout);
db.close();
}
This is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:layout_gravity="center_horizontal"
android:scrollbars="vertical|horizontal"
android:id="#+id/layout">
</RelativeLayout>
How do I fix this error?
Any help is appreciated! Thank you so much!

#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.students_masterlist);
db=openOrCreateDatabase("ClassManager",MODE_WORLD_WRITEABLE, null);
Cursor c=db.rawQuery("SELECT StudPic, StudentID, LastName FROM MasterStudents", null);
int count= c.getCount();
c.moveToFirst();
TableLayout tableLayout = new TableLayout(getApplicationContext());
tableLayout.setVerticalScrollBarEnabled(true);
TableRow tableRow;
TextView textView, textView1;
ImageView StudImageView;
RelativeLayout rl=(RelativeLayout)findViewById(R.id.layout);
ScrollView sv = new ScrollView(this);
sv.addView(tableLayout);
rl.addView(sv);
for (Integer j = 0; j < count; j++)
{
tableRow = new TableRow(getApplicationContext());
StudImageView = new ImageView(getApplicationContext());
StudImageView.setPadding(20, 20, 20, 20);
StudImage=c.getBlob(c.getColumnIndex("StudPic"));
Bitmap b1= BitmapFactory.decodeByteArray(StudImage, 0, StudImage.length);
StudImageView.setImageBitmap(b1);
tableRow.addView(StudImageView);
textView1 = new TextView(getApplicationContext());
textView1.setText(c.getString(c.getColumnIndex("StudentID")));
textView1.setPadding(20, 20, 20, 20);
textView1.setTextColor(getResources().getColor(R.color.blueactionbar));
textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP,25);
textView1.setTypeface(null, Typeface.BOLD);
tableRow.addView(textView1);
textView = new TextView(getApplicationContext());
textView.setText(c.getString(c.getColumnIndex("LastName")));
textView.setPadding(20, 20, 20, 20);
textView.setTextColor(getResources().getColor(R.color.blueactionbar));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP,25);
textView.setTypeface(null, Typeface.BOLD);
tableRow.addView(textView);
tableLayout.addView(tableRow);
c.moveToNext() ;
}
db.close();
rl.requestLayout();
}
The First setContentView is called with the parenet relative layout which contains the table layout that has your rows.Therefore you are trying to setContentView to a view which is contained in the parent that you have already setContentView to ie.
rl contains sv contains tableLayout.
but you are setting the activity view first to rl then to tableLayout.
Instead you should set the content view to rl.Then fill your tableLayout like you did and refresh the layout.ie call requestLayout() on the parent view.

Related

How to set one view in vertical linearlayout in top and another in bottom programmatically?

I'm trying to create programmatically parent LinearLayout
and 3 TextViews.
One TextView must be aligned in top left, the second one in the center of parent
and the third one to the right and bottom of my screen. Everything must be done in code.
I'm almost done, but there is still some problem.
All my 3 views are on the top
My code:
public class ActivityFour extends AppCompatActivity {
private LinearLayout mLinearLayout;
private TextView tv1;
private TextView tv2;
private TextView tv3;
private static final int TV_ID1 = 101;
private static final int TV_ID2 = 102;
private static final int TV_ID3 = 103;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLinearLayout = new LinearLayout(this);
mLinearLayout.setOrientation(LinearLayout.VERTICAL);
ViewGroup.LayoutParams llParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
setContentView(mLinearLayout, llParams);
LinearLayout.LayoutParams linlayout_params1 =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams linlayout_params2 =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams linlayout_params3 =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
linlayout_params1.setMargins(16,16,16,16);
tv1 = new TextView(this);
tv1.setId(TV_ID1);
linlayout_params1.gravity = Gravity.START;
linlayout_params1.gravity = Gravity.TOP;
mLinearLayout.addView(tv1, linlayout_params1);
tv1.setText("TextView number ONE");
linlayout_params2.setMargins(16,16,16,16);
tv2 = new TextView(this);
tv2.setId(TV_ID2);
linlayout_params2.gravity = Gravity.CENTER;
mLinearLayout.addView(tv2, linlayout_params2);
tv2.setText("TextView number TWO");
linlayout_params3.setMargins(16,16,16,16);
tv3 = new TextView(this);
tv3.setId(TV_ID3);
linlayout_params3.gravity = Gravity.END;
mLinearLayout.addView(tv3, linlayout_params3);
tv3.setText("TextView number THREE");
}
}
After adding the weight property to all view.params it looks like this
In order to make the LinearLayout fill all the available space, you need to set the android:layout_weight attribute on the middle child View. You can do it programmatically by using a Constructor which takes the weight as third parameter:
LinearLayout.LayoutParams linlayout_params2 =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
First of all no need to create liner layout for all textview you can do like this:
in xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:id="#+id/test"
tools:context=".activity.TestActivity"/>
and in activity file :
LinearLayout layout = findViewById(R.id.test);
TextView product_1 = new TextView(this);
product_1.setText("Product 1");
product_1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,0,1f));
layout.addView(product_1);
TextView product_2 = new TextView(this);
product_2.setText("Product 2");
product_2.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,0,1f));
product_2.setGravity(Gravity.CENTER);
layout.addView(product_2);
TextView product_3 = new TextView(this);
product_3.setText("Product 3");
product_3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,0,1f));
product_3.setGravity(Gravity.END|Gravity.BOTTOM);
layout.addView(product_3);

Dynamic TableLayout with TextView is empty even with values in ArrayList

I'm trying to create a dynamic TableLayout with data from database. I store the data in an ArrayList and use it to setText for the TextView. I used debug to check and the ArrayList had the correct number of values as in the database. It's not empty. But still the screen is blank. I tried to setTextColor for the TextView but it still was empty. The first 5 TextViews are for the heading. Later I use for loop for setting the text. I'm trying to do this in a Fragment btw.
Edit: I even checked the value of the bookingHistoryList.get(0). The value is correct. I can't display it!
Here's the code
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
sessionManager = new SessionManager(getActivity());
databaseHelper = new DatabaseHelper(getActivity());
bookingHistoryList = new ArrayList();
view = inflater.inflate(R.layout.fragment_preferences, container, false);
tableLayout = (TableLayout)view.findViewById(R.id.hTableLayout);
TableRow pickDate = new TableRow(getActivity());
TextView pickDateTxt = new TextView(getActivity());
pickDateTxt.setText("Pick up Date");
pickDate.addView(pickDateTxt);
TableRow pickTime = new TableRow(getActivity());
TextView pickTimeTxt = new TextView(getActivity());
pickTimeTxt.setText("Pick up Time");
pickTime.addView(pickTimeTxt);
TableRow pickUpLocation = new TableRow(getActivity());
TextView pickUpLocationTxt = new TextView(getActivity());
pickUpLocationTxt.setText("Pick up Location");
pickUpLocation.addView(pickUpLocationTxt);
TableRow destination = new TableRow(getActivity());
TextView destinationTxt = new TextView(getActivity());
destinationTxt.setText("Destination");
destination.addView(destinationTxt);
TableRow vehicleType = new TableRow(getActivity());
TextView vehicleTypeTxt = new TextView(getActivity());
vehicleTypeTxt.setText("Vehicle Type");
vehicleType.addView(vehicleTypeTxt);
// databaseHelper.delete();
String getUserEmail = sessionManager.getUserEmail();
bookingHistoryList = databaseHelper.getBookingHistory(sessionManager.getUserEmail());
rowCount = DatabaseUtils.queryNumEntries(databaseHelper.getReadableDatabase(),"bookingDetails");
n = (int) rowCount*5;
for(int i = 0; i<n; i++) {
TableRow tableRow = new TableRow(getActivity());
TextView textView = new TextView(getActivity());
textView.setText(bookingHistoryList.get(i).toString());
textView.setTextColor(Color.BLACK);
tableRow.addView(textView);
tableLayout.addView(tableRow,new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
TableRow tableRow1 = new TableRow(getActivity());
TextView textView1 = new TextView(getActivity());
textView1.setText(bookingHistoryList.get(i+1).toString());
tableRow1.addView(textView1);
tableLayout.addView(tableRow,new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
TableRow tableRow2 = new TableRow(getActivity());
TextView textView2 = new TextView(getActivity());
textView2.setText(bookingHistoryList.get(i+2).toString());
tableRow2.addView(textView2);
tableLayout.addView(tableRow,new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
TableRow tableRow3 = new TableRow(getActivity());
TextView textView3 = new TextView(getActivity());
textView2.setText(bookingHistoryList.get(i+3).toString());
tableRow2.addView(textView3);
tableLayout.addView(tableRow,new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
TableRow tableRow4 = new TableRow(getActivity());
TextView textView4 = new TextView(getActivity());
textView2.setText(bookingHistoryList.get(i+4).toString());
tableRow2.addView(textView4);
tableLayout.addView(tableRow,new TableLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
i += 4;
}
return view;
}
Here's the code to get from database. Its return value is not empty.
public ArrayList getBookingHistory(String email) {
ArrayList bookingHistoryList = new ArrayList();
String e = email;
Cursor c = db.rawQuery("select * from bookingDetails where email = '"+ email + "'", null);
int cou = c.getCount();
c.moveToFirst();
do {
bookingHistoryList.add(c.getString(c.getColumnIndex("date")));
bookingHistoryList.add(c.getString(c.getColumnIndex("time")));
bookingHistoryList.add(c.getString(c.getColumnIndex("fromLocation")));
bookingHistoryList.add(c.getString(c.getColumnIndex("destination")));
bookingHistoryList.add(c.getString(c.getColumnIndex("vehicle")));
} while (c.moveToNext());
return bookingHistoryList;
}
Stacktrace:
java.lang.NullPointerException
at com.prematixsofs.taxiapp.PreferencesFragment.onCreateView(PreferencesFragment.java:75)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:45)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5391)
Layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="com.looper.loop.PreferencesFragment">
<LinearLayout
android:id="#+id/fragmentPreferencesLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableLayout
android:id="#+id/hBookingHistoryTable"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TableLayout>
</ScrollView>
</LinearLayout>
</FrameLayout>
Two things :
One:
Your TableLayout id is hBookingHistoryTable. But in code, you are using a different id.
tableLayout = (TableLayout)view.findViewById(R.id.hTableLayout);
Change it to,
tableLayout = (TableLayout)view.findViewById(R.id.hBookingHistoryTable);
Two:
You are creating TableRows but not adding them to TableLayout. Add this line to all TableRows,
tableLayout.addView(<table_row_name>, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
Correct steps for dynamically add rows to a TableView :
TableLayout table = (TableLayout) findViewById(R.id.main_table);
TableRow row = new TableRow(this);
TextView item = new TextView(this);
item.setId(200+count);
item.setText(date);
row.addView(item);
table.addView(row, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

ScrollView with TableLayout programmatically Java

I have tried everything but my ScrollView doesn't work in my activity. I have activity where after user clicks button opens a table. I can't find a way that my table scrolls bouth ways. How can I make ScrollView programmatically? My code:
TableLayout tableLayout = new TableLayout(getApplicationContext());
tableLayout.setVerticalScrollBarEnabled(true);
tableLayout.setBackgroundColor(Color.WHITE);
TableRow tableRow;
TextView textView,...
tableRow = new TableRow(getApplicationContext());
textView=new TextView(getApplicationContext());
textView.setText("Date");
textView.setTextColor(Color.BLACK);
textView.setTypeface(null, Typeface.BOLD);
textView.setPadding(20, 20, 20, 20);
tableRow.addView(textView);
tableLayout.addView(tableRow);
for (Integer j = 0; j < count; j++)
{
tableRow = new TableRow(getApplicationContext());
textView1 = new TextView(getApplicationContext());
....
tableLayout.addView(tableRow);
c.moveToNext() ;
}
c.close();
setContentView(tableLayout);
database.close();
You can make it this way and in ScrollView there must be only one child:
ScrollView scrollview = new ScrollView(context);
scrollview.setBackgroundColor(android.R.color.transparent);
scrollview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
scrollview.addView(tableLayout);

how add and delete rows to table layout in java programically

I am new in java and android programing. I want to add rows(include some text box) to table layout by code and delete some of them.and finaly get their text box valus.how can i do it?
Here is a simple example to do what you want:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent">
</TableLayout>
Activity:
public class TableLayoutActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table_layout);
final TableLayout tableLayout = (TableLayout) findViewById(R.id.table);
for (int i = 0; i < 5; i++) {
// Creation row
final TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT));
// Creation textView
final TextView text = new TextView(this);
text.setText("Test" + i);
text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
// Creation button
final Button button = new Button(this);
button.setText("Delete");
button.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final TableRow parent = (TableRow) v.getParent();
tableLayout.removeView(parent);
}
});
tableRow.addView(text);
tableRow.addView(button);
tableLayout.addView(tableRow);
}
}
}
I recently got the same problem. I fixed it like this.
Suppose your TableLayout is called table and als has this id in the xml layout.
<TableLayout
android:id="#+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
Suppose you have a list of Person objects, this is the way to populate the table:
ArrayList<Person> persons = getPersonList(); // --> suppose getting the list from this function
TableLayout table = (TableLayout) findViewById(R.id.table);
for(Person person : persons) {
TableRow row = new TableRow(this);
TextView tvName = new TextView(this);
TextView tvAge = new TextView(this);
TextView tvMail = new TextView(this);
tvName.setText(person.getName());
tvAge.setText(String.valueOf(person.getAge());
tvMail.setText(person.getMail());
row.addView(tvName);
row.addView(tvAge);
row.addView(tvMail);
table.addView(row);
}
This basically means that each person has its own row. For every property of your person, 1 column is used.
Regards

why tablelayout's layout_width and _height is not covering the whole area of samsung tablet's screen?

Hi to all,
i have written something like this in the xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="#+id/tl_splash_screen" >
</TableLayout>
</LinearLayout>
and in java file
TableLayout tl_splash_screen;
int int_scr_wd;
TableRow tr_test;
TextView txt_test;
TableRow tr_test1;
TextView txt_test1;
TableRow tr_test2;
TextView txt_test2;
TableRow tr_test3;
TextView txt_test3;
TableRow tr_test4;
TextView txt_test4;
TableRow tr_test5;
TextView txt_test5;
int int_tb_bk_col;
int int_black;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.x_splash_screen);
try
{
txt_test=new TextView(this);
txt_test1=new TextView(this);
txt_test2=new TextView(this);
txt_test3=new TextView(this);
txt_test4=new TextView(this);
txt_test5=new TextView(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(int_scr_wd+300, LayoutParams.FILL_PARENT);
tr_test = (TableRow) new TableRow(this);
tr_test1 = (TableRow) new TableRow(this);
tr_test2 = (TableRow) new TableRow(this);
tr_test3 = (TableRow) new TableRow(this);
tr_test4 = (TableRow) new TableRow(this);
tr_test5 = (TableRow) new TableRow(this);
tl_splash_screen = (TableLayout)findViewById(R.id.tl_splash_screen);
int_tb_bk_col = Color.rgb(211,211,211);
int_black = Color.rgb(0,0,0);
tl_splash_screen.setBackgroundColor(int_tb_bk_col);
txt_test.setTextColor(int_black);
txt_test1.setTextColor(int_black);
txt_test2.setTextColor(int_black);
txt_test3.setTextColor(int_black);
txt_test4.setTextColor(int_black);
txt_test5.setTextColor(int_black);
Display display = getWindowManager().getDefaultDisplay();
int_scr_wd= display.getWidth();
int as = display.getHeight();
Log.i("", String.valueOf(int_scr_wd));
Log.i("", String.valueOf(as));
txt_test1.setHeight(120);
txt_test2.setHeight(120);
txt_test3.setHeight(120);
txt_test4.setHeight(120);
txt_test5.setHeight(120);
txt_test.setText("TextViews");
txt_test1.setText("- TextView 1");
txt_test2.setText("- TextView 2");
txt_test3.setText("- TextView 3");
txt_test4.setText("- TextView 4");
txt_test5.setText("- TextView 5");
tr_test.addView(txt_test);
tr_test1.addView(txt_test1);
tr_test2.addView(txt_test2);
tr_test3.addView(txt_test3);
tr_test4.addView(txt_test4);
tr_test5.addView(txt_test5);
tl_splash_screen.addView(tr_test,new TableLayout.LayoutParams(layoutParams));
tl_splash_screen.addView(tr_test1,new TableLayout.LayoutParams(layoutParams));
tl_splash_screen.addView(tr_test2,new TableLayout.LayoutParams(layoutParams));
tl_splash_screen.addView(tr_test3,new TableLayout.LayoutParams(layoutParams));
tl_splash_screen.addView(tr_test4,new TableLayout.LayoutParams(layoutParams));
tl_splash_screen.addView(tr_test5,new TableLayout.LayoutParams(layoutParams));
}
catch(Exception ex)
{
Log.i("caught error","caught while loading main page");
}
}
Just to demonstrate i have posted this code. You all can see that i have mentioned textview 5 in which "textview - 5" text is written which is not visible on the screen because i have not taken tablelayout under scrollable view.
all i want to ask that why table layout is covering some area of the screen even though i have defined it fill_parent.
Please suggest something.
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="false" />
Add this to your manifest file.

Categories