Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Display string with textView
    primarykey
    data
    text
    <p>hello i am trying to display a string with a <code>TextView</code>. i am doing this dynamically and this is the code:</p> <pre><code> LinearLayout layout=(LinearLayout) this.findViewById(R.id.Layout); EditText editText=(EditText) this.findViewById(R.id.textView); Button button=(Button) this.findViewById(R.id.btnAdd); LayoutParams lparams = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); TextView tv=new TextView(this); tv.setLayoutParams(lparams); tv.setText(display); this.layout.addView(tv); </code></pre> <p>,but it hits an error on <code>this.layout.addView(tv);</code> Can you please tell me what i am doing wrong?</p> <p>Thanks a lot in advance!</p> <p>Update(full activity code):</p> <pre><code>public class CalendarDate extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calendar_date); Bundle extras = getIntent().getExtras(); String dday = extras.getString("currentday"); String dmonth =extras.getString("currentmonth"); String dyear = extras.getString("currentyear"); ActionBar ab = getActionBar(); ab.setTitle(dday+"/"+dmonth+"/"+dyear ); Bundle extraz =getIntent().getExtras(); String display = extras.getString("EXTRA_MESSAGE"); setContentView(R.layout.activity_calendar_date); LinearLayout layout=(LinearLayout) this.findViewById(R.id.Layout); EditText editText=(EditText) this.findViewById(R.id.textView); Button button=(Button) this.findViewById(R.id.btnAdd); LayoutParams lparams = new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); TextView tv=new TextView(this); tv.setLayoutParams(lparams); tv.setText(display); layout.addView(tv); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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