Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add set text programmatically one below another?
    text
    copied!<p>I have set notification listener in my code. Whenever I receive a notification I want to put a Text view in my <code>linear layout</code> activity which has nothing initially.<br> When second notification arrives I want to add one more text view below the previous text view.</p> <pre><code>public class InformationActivity extends Activity { public static VideoInformationClass vidInfo = new VideoInformationClass() ; public static LinearLayout lv ; public static LayoutParams textViewParams; public static TextView tv ; public static TextView tv1,tv2,tv3,tv4,tv5,tv6,tv7,tv8,tv9,tv10; static int fieldFrequency; static int numberOfFrameLines; static int numberOfVisibleLines; static int numberOfVisiblePixels; static int interlace; static int imageFormat; static int videoCoding; static int scanType; VideoPropertiesParams GetParams; VideoPropertiesParams VP; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.information_activity); Context context = getBaseContext(); LinearLayout lv = new LinearLayout(this); lv.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // tv = new TextView(this); } @Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); onFieldFrequencyChanged(); onImageFormatChanged(); onInterlacedChanged(); /*vidInfo.RegisterVidPropertyListener(); vidInfo.RegisterSignalAndPresenceListener(); vidInfo.RegisterThreeDChangeListener();*/ if (ControlUnit.flag) { GetParams = vidInfo.GetVideoProperty(); Log.i("TvPlayerFunctionalTestApp","Get Video Property called"); fieldFrequency = GetParams.fieldFrequency; numberOfFrameLines = GetParams.numberOfFrameLines; numberOfVisibleLines = GetParams.numberOfVisibleLines; numberOfVisiblePixels = GetParams.numberOfVisiblePixels; interlace = GetParams.interlace; imageFormat = GetParams.imageFormat; videoCoding = GetParams.videoCoding; scanType = GetParams.scanType; } /* tv.setText("Something"); tv.setLayoutParams(textViewParams); lv.addView( tv );*/ } @Override protected void onStop() { // TODO Auto-generated method stub super.onStop(); /*vidInfo.UnRegisterSignalAndPresenceListener(); vidInfo.UnRegisterThreeDChangeListener(); vidInfo.UnRegisterVidPropertyListener();*/ } public void onFieldFrequencyChanged(){ String info = "On field frequency changed , value is " + vidInfo.ChangedFrequency; tv = new TextView(this); tv.setText(String.valueOf(info)); LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tv.setLayoutParams(textViewParams); lv.addView(tv); } public void onImageFormatChanged() { String info = "On Image Format changed , value is " + vidInfo.ChangedFormat; tv1 = new TextView(this); tv1.setText(String.valueOf(info)); LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tv1.setLayoutParams(textViewParams); lv.addView(tv1 ); } public void onInterlacedChanged() { String info = "On Interlaced changed , value is " + vidInfo.InterlaceChange; tv.setText(String.valueOf(info)); LinearLayout.LayoutParams textView Params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tv.setLayoutParams(textViewParams); lv.addView(tv); } </code></pre>
 

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