0

I have defined the function showMeTable() for getting data from sqlite database in DbHelper.java class. Then i call it from WeekDbShow.java class. After getting the table in the form of string , i am setting it to a textView .Here is the part of my DbHelper.java class .

public String showMeTable() { String mStr=""; mStr=mStr.concat("<body >"); mStr=mStr.concat("<tr><td align='center'><b>period</b></td><td align='center'><b>Monday</b></td>" + "<td align='center'><b>Tuesday</b></td><td align='center'><b>Wednesday</b></td><td align='center'><b>Thrusday</b></td>" + "<td align='center'><b>Friday</b></td></tr>"); String[] columns=new String[]{KEY_ROWID,KEY_PERIOD,KEY_MON,KEY_TUES,KEY_WED,KEY_THRUS,KEY_FRI};//KEY_MON may be instead of weekDay Cursor cursor=OurDb.query(DATABASE_TABLE,columns,null,null,null,null,null); cursor.moveToFirst(); while(!cursor.isAfterLast()) { mStr=mStr.concat("<tr><td>"+(cursor.getString(cursor.getColumnIndex(KEY_PERIOD)))+"</td>" + "<td>"+(cursor.getString(cursor.getColumnIndex(KEY_MON)))+"</td><td>"+ (cursor.getString(cursor.getColumnIndex(KEY_TUES)))+"</td><td>"+(cursor.getString(cursor.getColumnIndex(KEY_WED)))+"</td>" + "<td>"+(cursor.getString(cursor.getColumnIndex(KEY_THRUS)))+"</td><td>"+(cursor.getString(cursor.getColumnIndex(KEY_FRI)))+"</td></tr>"); cursor.moveToNext(); } mStr.concat("</table></body>"); return mStr; } 

And this is the part of my WeekDbShow.java class from where i am calling the showMeTable.

 String data=myDbHelper.showMeTable(); //showMe.setText("<b>data</b>"); showMe.setText(Html.fromHtml(data)); myDbHelper.close(); 

here is my xml file.

<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:id="@+id/tvTT" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Medium Text" android:maxLines = "200" android:scrollbars = "vertical" /> 

please give me some good solution ,i have all ready tried scrollView in xml.

4

4 Answers 4

3

In properties of your TextView in your layout's xml file set:

android:scrollbars = "vertical" 
Sign up to request clarification or add additional context in comments.

Comments

2

If you r using AS then above fix may not work ....try this...... In properties of your TextView in your layout's xml file set:

android:scrollbars = "vertical" 

Comments

2

Try adding scrollable = true and scrollbar = vertical in your text view properties in the layout xml..

3 Comments

i don,t understand ,plss be more specific.
What I meant was add android:scrollable="true" and android:scrollbars="vertical" in your XML..
there is no scrollable field for TextView.
0

You can also do this in programatically(.class) by adding this lines

yourtextView.setVerticalScrollBarEnabled(true); yourtextView.setMovementMethod(new ScrollingMovementMethod()); 

Refer this link for more details.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.