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);

PORTRAIT ORIENTATION OF THE SCREEN ;

setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);


LANDSCAPE ORIENTATION OF THE SCREEN ;

setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

EDITTEXT SELECT ALL ON FOCUS;

edittext1.setSelectAllOnFocus(true);

TEXT OF THE VOICE ;

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);  }  } );

ONCLICKLISTENER IS ONTOUCHLISTENER ;

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 LONG MESSAGE ;

Toast.makeText(getApplicationContext(), "Your Message", Toast.LENGTH_LONG).show();


SET TEXT COLOR RGB :

textview1.setTextColor(Color.rgb(73,82,178));


SET TEXT COLOR HEX :

textview1.setTextColor(Color.parseColor("#000000"));


DIALOG SET CANCELABLE :

mydialog.setCancelable(false);


SHOW EDITTEXT DIALOG :

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);


EDITTEXT DISABLE SUGGESTIONS ( MULTI LINE ) :

edittext1.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

EDITTEXT DISABLE SUGGESTIONS ( SINGLE LINE ) :

edittext1.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);


WEBVIEW SET JAVASCRIPT;

webview1.getSettings().setJavaScriptEnabled(true);

WEBVIEW SET COOKIES ;

CookieManager.getInstance().setAcceptCookie(false);