Using Eclipse for Android development... Going to make a geocaching application
ID: 665943 • Letter: U
Question
Using Eclipse for Android development... Going to make a geocaching application so to start I need help with this. I cannot get Eclipse to allow me to debug once I have either view of the xml file on. Even for Hello World....I have android sdk in the right folder, and set up how it should I think. It just won't debug so if you can help me with that, great.
I also need to:
Using the Intent, startActivity() method, crea te buttons that will allow the user to call up a screen or, where appropriate, close (finish) the current screen. Make them attractive and play with an appropriate layout.
Create a button for each of the following:
A splash screen
Main Menu screen
User Profile screen
Game Play screen
Help screen
Thanks in advanced
Explanation / Answer
ok..first I will explain installation steps... so that you can correct where you made installation wrong...
step 1) First run the .exe file you downloaded.
step2) Set up environment variables
Select Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for exampleC:Program FilesJavajdk1.7.0_21.
step 3)
The individual tools and other SDK packages are saved outside the Android Studio application directory. If you need to access the tools directly, use a terminal to navigate to the location where they are installed. For example:
Users<user>sdk
step4) downlad required tools
--------------------------------------------------------------
activity_my.xml
-------------------
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/splash_screen"
android:onClick="splash" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/main"
android:onClick="main" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/profile"
android:onClick="profile" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/game_play"
android:onClick="play" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/help"
android:onClick="help" />
MyActivity.java
-------------------------------------
public void splash(View view) {
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);
}
public void main(View view) {
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);
}
public void profile(View view) {
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);
}
public void play(View view) {
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);
}
public void help(View view) {
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);
}
---------------------------------------------------------
public class DisplayMessageActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() { }
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_display_message,
container, false);
return rootView;
}
}
}
---------------------------------------------------------------
strings.xml
<resources>
<string name="title_activity_display_message">My Message</string>
</resources>
------------------------------------------------------------------------
AndroidManifest.xml
<application>
<activity
android:name="com.mycompany.myfirstapp.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.mycompany.myfirstapp.MyActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mycompany.myfirstapp.MyActivity" />
</activity>
</application>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.