Handy Android methods

//Log Message
String msg = "Nitin inside MainActivity: ";
Log.e(msg,"Inside BroadCast Intent Method in Main Activity");

//Toast Message
Toast.makeText(getApplicationContext(),"Flashing Message", Toast.LENGTH_LONG).show();
Toast.makeText(this,"Flashing Message", Toast.LENGTH_LONG).show();
//sending the intent from mainActivity to TweetListActivity
Intent intent = new Intent(MainActivity.this, Next_Activity_To_Go.class);
startActivity(intent);
//Picking up the values from the TextBox which is called EDITTEXT View (R.id.enter_username) in Android.

EditText userName = (EditText) findViewById(R.id.enter_username);
//Convert into String
String userNameValue = userName.getText().toString();
//Check the result in LogCat
Log.d("CodeLearn","username cought = " + userNameValue);
// For on Click of a LIST
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
/* Picking up the tweetTitle textView and change its value */
//TextView t = (TextView) v.findViewById(R.id.tweetTitle);
//t.setText("Tweet Clicked");

//Calling another page (TweetDetail Activity)
Intent intent = new Intent(this, TweetDetailActivity.class);
startActivity(intent);
}

/* OnClickListener for a Button */

//Inline
findViewById(R.id.button).setOnClickListener(new View.OnClick
@Override
public void onClick(View v){
Toast.makeText(this, "Button Clicked :)", Toast.LENGTH_SHORT);
}
});
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	/*setContentView is called withthe constant at
	 * R.layout.main to set the layoutcdefined in main.xml on the screen 
	 */
	setContentView(R.layout.activity_main);	
	}
@Override
public void onClick(View v) {
// Launch Activity Two
// Hint: use Context's startActivity() method
// Create an intent stating which Activity you would like to
// start
        Intent intent = null;
	intent = new Intent(ActivityOne.this, ActivityTwo.class);
// Launch the Activity using the intent
	startActivity(intent);
//in one Line
        startActivity(new Intent(ActivityOne.this, ActivityTwo.class));
}

Leave a Reply

Your email address will not be published. Required fields are marked *