Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created April 13, 2013 11:21
Show Gist options
  • Save pbrewczynski/5378013 to your computer and use it in GitHub Desktop.
Save pbrewczynski/5378013 to your computer and use it in GitHub Desktop.
package com.example.myfirstapp;
import android.app.Activity;
import android.os.Bundle;
// paul
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
import com.example.myfirstapp.DisplayMessageActivity;
public class MainActivity extends Activity
{
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void sendMessage(View view) {
// do something resposnes to button
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.annotation.SuppressLint;
import android.widget.TextView;
import com.example.myfirstapp.MainActivity;
public class DisplayMessageActivity extends Activity {
/*
@SupressLint("NewApi")
@Overrride
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.avtivity_display_message);
// Make sure we've running on Honeycom or highter to use ActionBar APIs
//if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the up button in the action bar
//getActionBar().setDispalyHomeAsUpEnabled(true);
//}
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
setContentView(textView);
}
/*
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
*/
}
-pre-compile:
-compile:
[javac] Compiling 3 source files to /root/an/MyFirstApp/bin/classes
[javac] /root/an/MyFirstApp/src/com/example/myfirstapp/DisplayMessageActivity.java:7: error: duplicate class: DisplayMessageActivity
[javac] public class DisplayMessageActivity extends Activity {
[javac] ^
[javac] /root/an/MyFirstApp/src/com/example/myfirstapp/MainActivity.java:9: error: cannot access DisplayMessageActivity
[javac] import com.example.myfirstapp.DisplayMessageActivity;
[javac] ^
[javac] bad source file: /root/an/MyFirstApp/src/com/example/myfirstapp/DisplayMessageActivity.java
[javac] file does not contain class com.example.myfirstapp.DisplayMessageActivity
[javac] Please remove or make sure it appears in the correct subdirectory of the sourcepath.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment