title: set text to textview in dynamically in android-marquee
body: <p>How to set TextView Text as dynamically for scrolling marquee.
  Please Help me Thanks Advance.</p>
  
  <p>The Listview used for getting the list item to be played in the audio player is as follows.</p>
  
  <pre><code>    public class Audiovediolist extends Activity implements OnItemClickListener {
          private ListView audioList;
          private Intent frmHome;
          private ArrayList&lt;HashMap&lt;String, String&gt;&gt; dataList;
          private HashMap&lt;String, String&gt; map;
          private HashMap&lt;String, String&gt; data;
          private int Screen_Id;
          String name;
          String mSign[] ={"1","2","3","4","5"}; 
          Integer mImages[] = { R.drawable.m, R.drawable.v,
                  R.drawable.mm, R.drawable.k, R.drawable.s};
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              requestWindowFeature(Window.FEATURE_RIGHT_ICON);
              setContentView(R.layout.list);
              frmHome = getIntent();
              getIntentValues();
              initUI();
              setUI();
              uiListener();
          }
          private void initUI() {
                  audioList = (ListView) findViewById(R.id.audiolist_listView);
                  dataList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          }
          private void uiListener() {
                  audioList.setOnItemClickListener(this);
          }
          private void getIntentValues() {
              String id = frmHome.getStringExtra("Activity_Id");
              Screen_Id = Integer.parseInt(id);
              if (Screen_Id == 1) {
                  getWindow().setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON,
                          R.drawable.audioo);
                  this.setTitle(getResources().getString(R.string.audio));
                  this.setTitleColor(getResources().getColor(R.color.Beige));
              } else {
                  this.setTitle(getResources().getString(R.string.video));
                  this.setTitleColor(getResources().getColor(R.color.Beige));
                  getWindow().setFeatureDrawableResource(Window.FEATURE_RIGHT_ICON,
                          R.drawable.videoo);
                   }
            }
          private void setAdapter() {
              SimpleAdapter adapter = new SimpleAdapter(this, dataList,
                                       R.layout.list_row, new String[] { "Image", "text" },
                                       new int[] {
                                       R.id.audiolist_row_img, R.id.audiolist_row_tv });
                           audioList.setAdapter(adapter);
          }
          private void setUI() {
                  for (int a = 0; a &lt;= 11; a++) {
                       map = new HashMap&lt;String, String&gt;();
                       map.put("Image", "" + mImages[a]);
                       map.put("text", mSign[a]);
                       dataList.add(map);
                       map = null;
                  }
          }
          @Override
          protected void onStart() {
              super.onStart();
              setAdapter();
          }
          @Override
          public void onBackPressed() {
              super.onBackPressed();
              System.gc();
          }
      /*private class NextTask extends AsyncTask&lt;Void,Void,Void&gt; {
                  ProgressDialog progressDailog = new ProgressDialog(Audiovediolist.this);
                @Override
                protected void onPreExecute() {
                  super.onPreExecute();
                  progressDailog.setTitle("Please Wait");
                  progressDailog.setMessage("URL Data Loading ...");
                  progressDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                  progressDailog.setCancelable(true);
                  progressDailog.show();
                  }
                @SuppressWarnings("static-access")
              @Override
                protected Void doInBackground(Void... params) {
                  return null;
                  }
               @Override
               protected void onPostExecute(Void result) {
                  progressDailog.dismiss();
                  }
      }*/
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
              long id) {
                      data = dataList.get(position);
                  try {
                        NetWorkCheck netWork = new NetWorkCheck();
                        if (netWork.isNetWorkConnection(this)) {
                            if (Screen_Id == 1) {
                              //  new NextTask().execute();
                                Intent audioInt=new Intent(getApplicationContext(),AudioView.class);
                                  audioInt.setType(data.get("text"));
                                  startActivity(audioInt);
                             } else if (Screen_Id == 2) {
                                   Intent vedioInt = new Intent(this, VideoPlayActivity.class);
                                   vedioInt.setType(data.get("text"));
                                   startActivity(vedioInt);
                                   }
                         } else {
                                netWork.alert();
                                }  
                      } catch (Exception e) {
                              e.printStackTrace();
                              Toast.makeText(this, "Problem while ListItemClick", Toast.LENGTH_SHORT).show();
                              }
      }
      }
  </code></pre>
  
  <p>The code for audio player used is </p>
  
  <pre><code>public class AudioView extends Activity implements OnClickListener {
      private MediaPlayer mMediaPlayer;
      private ImageView mPlay;
      private ImageView mPause;
      private ImageView mBack;
      private ImageView mFar;
      private ProgressBar myProgressBar;
      // private PlayerService mService;
      private boolean boolFlag = false;
      private boolean isPausedInCall = false;
      private String url;
      private TelephonyManager mTelephoneMgr;
      private NotificationManager mNotificationManager;
      private int SIMPLE_NOTFICATION_ID;
      private TextView tv;
      // private boolean serviceRunning;
      Notification notifyDetails;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
          setContentView(R.layout.audio_main);
          getIntentValues();
          initUI();
          uiListener();
          mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
          notifyDetails = new Notification(R.drawable.mulug_icon, url,
                  System.currentTimeMillis());
  
          mTelephoneMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
          if (mTelephoneMgr != null) {
              mTelephoneMgr.listen(phoneStateListener,
                      PhoneStateListener.LISTEN_CALL_STATE);
          }
      }
  
      private void getIntentValues() {
          url = getIntent().getType();
  
  
      }
  
      private void uiListener() {
          mPlay.setOnClickListener(this);
          mPlay.setOnClickListener(this);
          mPause.setOnClickListener(this);
          mPause.setVisibility(android.view.View.INVISIBLE);
          mBack.setOnClickListener(this);
          mFar.setOnClickListener(this);
      }
  
      private void initUI() {
          tv = (TextView) findViewById(R.id.text);
          mBack = (ImageView) findViewById(R.id.back);
          mPlay = (ImageView) findViewById(R.id.play);
          mPause = (ImageView) findViewById(R.id.pause);
          mFar = (ImageView) findViewById(R.id.fwd);
          myProgressBar = (ProgressBar) findViewById(R.id.progressbar_Horizontal);
          myProgressBar.setProgressDrawable(getResources().getDrawable(
                  R.drawable.green_progress));
          myProgressBar.setProgress(0);
              tv.setText(url);
              tv.setFocusable(true);
      }
  
      private Thread myThread = new Thread() {
          public void run() {
              while (mMediaPlayer.getCurrentPosition() &lt; mMediaPlayer
                      .getDuration()) {
                  try {
                      myProgressBar
                              .setProgress(mMediaPlayer.getCurrentPosition());
                  } catch (Throwable t) {
                  }
              }
          }
      };
  
      @SuppressLint("NewApi")
      @Override
      public void onBackPressed() {
          super.onBackPressed();
          mMediaPlayer.stop();
          // myThread.stop();
          // mMediaPlayer.release();
          mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
          System.gc();
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          System.gc();
      }
      @SuppressLint("NewApi")
      @Override
      protected void onStart() {
          super.onStart();
          this.setProgressBarIndeterminateVisibility(true);
          try {
              if (boolFlag == false) {
                  System.out.println(FinalConstants.URL + "mobile-audio/" + url
                          + ".mp3");
                  mMediaPlayer = MediaPlayer.create(
                          this,
                          Uri.parse(FinalConstants.URL + "mobile-audio/" + url
                                  + ".mp3"));
              }
              myProgressBar.setMax(mMediaPlayer.getDuration());
          } catch (Exception e) {
              Toast.makeText(getApplicationContext(), "Loading Problems",
                      Toast.LENGTH_SHORT).show();
              Log.e("ERRORS", "ServerFailed to Load...");
              super.onBackPressed();
              e.printStackTrace();
          }
      }
  
      public PhoneStateListener phoneStateListener = new PhoneStateListener() {
          @Override
          public void onCallStateChanged(int state, String incomingNumber) {
              if (state == TelephonyManager.CALL_STATE_RINGING) {
                  System.out.println("ringing state");
                  if (mMediaPlayer != null) {
                      pauseMedia();
                      isPausedInCall = true;
                  }
                  notificationShow();
              }
              if (state == TelephonyManager.CALL_STATE_IDLE) {
                  System.out.println("callState Idle");
                  if (mMediaPlayer != null) {
                      if (isPausedInCall) {
                          isPausedInCall = false;
                          playMedia();
                      }
                  }
              }
              if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
              }
              super.onCallStateChanged(state, incomingNumber);
          }
      };
  
      private void pauseMedia() {
          mMediaPlayer.pause();
          changePlayerIcons(false);
      }
  
      private void playMedia() {
          mMediaPlayer.start();
          changePlayerIcons(true);
      }
  
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.play:
              if (!boolFlag) {
                  try {
                      notificationShow();
                      mMediaPlayer.setLooping(false);
                      // mMediaPlayer.prepareAsync();
                  } catch (Exception e) {
                      Toast.makeText(this, "preparing", Toast.LENGTH_SHORT)
                              .show();
                  }
                  boolFlag = true;
                  mMediaPlayer.start();
                  myThread.start();
              } else {
                  notificationShow();
                  mMediaPlayer.getCurrentPosition();
                  mMediaPlayer.start();
              }
              changePlayerIcons(true);
              myProgressBar.setProgress(mMediaPlayer.getCurrentPosition());
              mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
                  @Override
                  public void onCompletion(MediaPlayer arg0) {
                      changePlayerIcons(false);
                      myProgressBar.setProgress(0);
                      onStart();
                  }
              });
              mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
                  @Override
                  public void onPrepared(MediaPlayer mp) {
                  }
              });
              mMediaPlayer.setOnErrorListener(new OnErrorListener() {
                  @Override
                  public boolean onError(MediaPlayer mp, int what, int extra) {
                      Toast.makeText(getApplicationContext(),
                              "MediaPlayer Errors", Toast.LENGTH_SHORT).show();
                      Log.e("ERRORS", "MediaPlayer Errors...");
                      return false;
                  }
              });
              break;
          case R.id.pause:
              mMediaPlayer.pause();
              mPlay.setVisibility(android.view.View.VISIBLE);
              mPause.setVisibility(android.view.View.INVISIBLE);
              break;
          case R.id.back:
              int dur = mMediaPlayer.getCurrentPosition();
              int pos = (dur &gt; 10000 ? dur - 5000 : 0);
              mMediaPlayer.seekTo(pos);
              break;
          case R.id.fwd:
              int curpos = mMediaPlayer.getCurrentPosition();
              int dur2 = mMediaPlayer.getDuration();
              int pos2 = (curpos + 5000 &gt; dur2 ? dur2 : curpos + 5000);
              mMediaPlayer.seekTo(pos2);
              break;
          }
      }
  
      private void notificationShow() {
          Context context = getApplicationContext();
          CharSequence contentTitle = "Mulugu Running";
          CharSequence contentText = url + " Weekly Predictions";
          Intent notifyIntent = new Intent(AudioView.this, AudioView.class);
          PendingIntent intent = PendingIntent.getActivity(AudioView.this, 0,
                  notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
  
          notifyDetails.setLatestEventInfo(context, contentTitle, contentText,
                  intent);
          mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
      }
  
      private void changePlayerIcons(boolean b) {
          if (b) {
              mPlay.setVisibility(android.view.View.INVISIBLE);
              mPause.setVisibility(android.view.View.VISIBLE);
          } else {
              mPlay.setVisibility(android.view.View.VISIBLE);
              mPause.setVisibility(android.view.View.INVISIBLE);
          }
      }
  }
  </code></pre>
  
  <p>The XML used is </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:background="@drawable/main_audio"
          android:orientation="horizontal" &gt;
  
  
          &lt;LinearLayout
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="bottom"
              android:gravity="center"
              android:orientation="vertical" &gt;
  
              &lt;LinearLayout
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_weight="0.45"
                  android:orientation="vertical" &gt;
  
  
                  &lt;TextView
                      android:id="@+id/text"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:layout_marginBottom="2dp"
                      android:ellipsize="marquee"
                      android:focusable="true"
                      android:focusableInTouchMode="true"
                      android:gravity="center_horizontal"
                      android:marqueeRepeatLimit="marquee_forever"
                      android:scrollHorizontally="true"
                      android:singleLine="true"
                      android:text="     for more details check on  "
                      android:textColor="#FF0000"
                      android:textSize="20dp"
                      android:textStyle="italic" &gt;
  
                  &lt;/TextView&gt;
              &lt;/LinearLayout&gt;
  
              &lt;RelativeLayout
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="3dp" &gt;
  
                  &lt;ImageView
                      android:id="@+id/pause"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="10dp"
                      android:src="@drawable/audio_pause" /&gt;
  
                  &lt;ImageView
                      android:id="@+id/play"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_centerHorizontal="true"
                      android:layout_marginLeft="2dp"
                      android:layout_marginTop="10dp"
                      android:src="@drawable/audio_play" /&gt;
  
                  &lt;ImageView
                      android:id="@+id/back"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_alignBottom="@+id/pause"
                      android:layout_marginRight="1dp"
                      android:layout_toLeftOf="@+id/pause"
                      android:layout_toRightOf="@drawable/audio_play"
                      android:src="@drawable/audio_bwd" /&gt;
  
                  &lt;ImageView
                      android:id="@+id/fwd"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_alignTop="@+id/pause"
                      android:layout_marginLeft="1dp"
                      android:layout_toRightOf="@+id/pause"
                      android:src="@drawable/audio_fwd" /&gt;
              &lt;/RelativeLayout&gt;
  
              &lt;ProgressBar
                  android:id="@+id/progressbar_Horizontal"
                  style="?android:attr/progressBarStyleHorizontal"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content" /&gt;
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>