CREATE WIDGET ;
//EditText
final EditText myedit = new EditText(ProjectinActivity.this); myedit.setHint("Your Hint"); myedit.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(myedit);
//TextView
final TextView mytext = new TextView(ProjectinActivity.this); mytext.setText("Your Text"); mytext.setTextColor(0xFF000000); mytext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(mytext);
//Button
final Button mybutton = new Button(ProjectinActivity.this); mybutton.setText("Your Button"); mybutton.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylinear.addView(mybutton);
//ProgressBar(Cicle) linear1 is an LinearLayout and MainActivity is your activity
ProgressBar msg = new ProgressBar(MainActivity.this); linear1.addView(msg);
//ProgressBar
ProgressBar tp = new ProgressBar(this,null, android.R.attr.progressBarStyleHorizontal); linear1.addView(tp,700,30); tp.setIndeterminate(true);
//RatingBar
RatingBar tp = new RatingBar(this); linear1.addView(tp);
0 Comments: