Pls help me with the problems:
This is my mainactivity source code
The errors I get are marked in bold
//package org.anddev.android.subactivitywithresult;
package com.android.mainactivity;
import android.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
//import com.android.R;
import android.app.Activity;
import android.os.Bundle;
public class Mainactivity extends Activity {
protected static final int SUB_ACTIVITY_REQUEST_CODE = 1337;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Apply our main.xml-Layout
setContentView(R.layout.main); //1) R.layout.main cannot be resolve
// Find the button defined in the main.xml
Button cmd_opensub = (Button)findViewById(R.id.mainactivity_cmd_opensub); // R.id.mainactivity_cmd_opensub cannot be resolved
// Add an OnClickListener to it, that will open the SubActivity
cmd_opensub.setOnClickListener(new OnClickListener(){
// @Override
public void onClick(View arg0) {
Intent i = new Intent(MainActivity.this, // Main activity cannot be resolved to a type
SubActivityWithResult.class);
// We use SUB_ACTIVITY_REQUEST_CODE as an 'identifier'
startSubActivity(i, SUB_ACTIVITY_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
String data, Bundle extras) {
super.onActivityResult(requestCode, resultCode, data, extras);
// Here We identify the subActivity we starte
if(requestCode == SUB_ACTIVITY_REQUEST_CODE){
// And show its result
showAlert("SubActivity returned", "ReturnValue: " + data,
"OK", false);
}
}
}
An error on showAlert, onActivityResult as well is shown
The subactivitywithresult code is:
//package org.anddev.android.subactivitywithresult;
package com.android.subactivitywithresult;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class SubActivityWithResult extends Activity{
protected final int SUCCESS_RETURN_CODE = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Apply our subactivity.xml-Layout
setContentView(R.layout.subactivity);
// Find the button defined in the subactivity.xml
Button cmd_return = (Button)findViewById(R.id.subactivity_cmd_return);
/* Add an OnClickListener to it, that will
* read out the text in the EditBox set it
* as retrn-data and close this activity */
cmd_return.setOnClickListener(new OnClickListener(){
// @Override
public void onClick(View arg0) {
// Find the edittext defined in the subactivity.xml
EditText edit_returvalue = (EditText)findViewById(
R.id.subactivity_edit_returnvalue);
SubActivityWithResult.this.setResult(SUCCESS_RETURN_CODE,
edit_returvalue.getText().toString());
// Close this Activity
SubActivityWithResult.this.finish();
}
});
}
}
The AndroidManifest.xml code is: Also gives errors
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.anddev.android.subactivitywithresult">
<application android:icon="@drawable/icon">
<activity class=".MainActivity" android:label="@string/main_app_name">
<intent-filter>
<action android:value="android.intent.action.MAIN" />
<category android:value="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity class=".SubActivityWithResult" android:label="@string/sub_app_name">
<intent-filter>
<action android:value="android.intent.action.VIEW" />
<category android:value="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
pls help with all these errors:
Anyone worked on SDK 0.9 with this code, pls post the working code.
Thanks a lot!





