//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);
setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
edittext1.setSelectAllOnFocus(true);
final android.speech.tts.TextToSpeech t1 = new android.speech.tts.TextToSpeech(getApplicationContext(), new android.speech.tts.TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if(status == android.speech.tts.TextToSpeech.ERROR) { Toast.makeText(getApplicationContext(), "Error",Toast.LENGTH_SHORT).show(); } } } ); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View _v) { String sentence = edittext1.getText().toString(); Toast.makeText(getApplicationContext(), sentence,Toast.LENGTH_SHORT).show(); t1.speak(sentence,android.speech.tts.TextToSpeech.QUEUE_FLUSH, null); } } );
WIDGET.setOnTouchListener(new OnTouchListener() { PointF DownPT = new PointF(); PointF StartPT = new PointF(); @Override public boolean onTouch(View v, MotionEvent event) { int eid = event.getAction(); switch (eid) {
case MotionEvent.ACTION_MOVE : PointF mv=new PointF( event.getX() - DownPT.x, event.getY() - DownPT.y); img.setX((int)(StartPT.x+mv.x)); img.setY((int)(StartPT.y+mv.y)); StartPT= new PointF(img.getX(), img.getY()); break;
case MotionEvent.ACTION_DOWN : DownPT.x = event.getX(); DownPT.y = event.getY(); StartPT = new PointF(img.getX(), img.getY() ); break;
case MotionEvent.ACTION_UP : float distance = DownPT.x - event.getX(); if (distance == 0) { //block } break; default : break;} return true;} });
Toast.makeText(getApplicationContext(), "Your Message", Toast.LENGTH_LONG).show();
textview1.setTextColor(Color.rgb(73,82,178));
textview1.setTextColor(Color.parseColor("#000000"));
mydialog.setCancelable(false);
LinearLayout mylayout = new LinearLayout(this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mylayout.setLayoutParams(params); mylayout.setOrientation(LinearLayout.VERTICAL); final EditText myedittext = new EditText(this); myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); mylayout.addView(myedittext); mydialogcomp.setView(mylayout);
edittext1.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
edittext1.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);