Note that there are some explanatory texts on larger screens.

plurals
  1. POTextView Scrolling Issue
    primarykey
    data
    text
    <p>Hii</p> <p>I was coding for an application that shows the list of running process and i was using TextView to display the running process in screen. I was trying 2 different method for displaying the TextView. In one method i was declearing the TextView in the code itself</p> <pre><code>TextView tv = new TextView(this); this.setContentView(tv); </code></pre> <p>In the second method i was declearing the layout in the main.xml file</p> <pre><code>setContentView(R.layout.main); TextView tv=(TextView) findViewById(R.id.RunApp); </code></pre> <p>For both the methods i am using the setMovementMethod for having the scroll movement for my TextView</p> <pre><code>tv.setMovementMethod(new ScrollingMovementMethod()); </code></pre> <p>The program is running fine in the emulator.But if i am using the second method then the scrolling is not happening if i am running the application in my mobile. In the emulator its working fine. Why is it behaving differently in my Android 2.1 Samsung Galaxy S?? Why the scrolling not happening in the second method??. Scrolling is happening in the first method without any issues in my mobile.</p> <p>This is my code..</p> <pre><code>public class listRunningApps extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); //TextView tv=(TextView) findViewById(R.id.RunApp); TextView tv = new TextView(this); this.setContentView(tv); tv.setMovementMethod(new ScrollingMovementMethod()); ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE ); List&lt;RunningAppProcessInfo&gt; procInfos = actvityManager.getRunningAppProcesses(); for(int j=0; j &lt; 2; j++) /*I have done iteration 2 times so that we have a long process list sufficeint enough for scrolling*/ { for(int i = 0; i &lt; procInfos.size(); i++) { tv.setText(tv.getText().toString()+procInfos.get(i).processName+ " " + String.valueOf(procInfos.get(i).processName.length())+"\n"); } tv.setText(tv.getText().toString()+"----------------------------"+"\n"); } } } </code></pre> <p>This is my main.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:id="@+id/jsttxt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Testing TextView Scrolling"/&gt; &lt;TextView android:id="@+id/RunApp" android:layout_marginLeft="30px" android:layout_marginRight="30px" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/jsttxt" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>In the first method the scrolling is coming in my mobile without any issue..Can you guys help me why the scrolling is not happening in my mobile in the second method, where as its working properly in my emulator?? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload