yesterday i created a Desk clock for android. For this I created a RelativeLayout to show Hours,minutes,etc... and a menu to show the options About, and Exit...Well, all works fine, but the problem comes when I click About Option: it force Closes and LogCat shows this:
E/AndroidRuntime(14751): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.iamaner.T2Speech/com.iamaner.T2Speech.FrmAbout}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
So I hope you can help me... Ive heard about this code, but i dont know where to put it,and how, i thought this would be Ok but it seems not
final RelativeLayout fondo = (RelativeLayout)findViewById(R.id.your_layout);((RelativeLayout)fondo.getParent()).removeView(fondo);
//scrollView.removeView(scrollChildLayout);
Here is the manifest file i think its the problem, i dont know:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".TimeToSpeechActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FrmAbout" />
</application>
And here, the FrmAbout code:
public class FrmAbout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frmabout);
TextView txtVersion = (TextView)findViewById(R.id.Txtversion);
TextView txtWarning = (TextView)findViewById(R.id.Txtwarning);
TextView txtInstructions = (TextView)findViewById(R.id.Txtinstructions);
TextView txtContact = (TextView)findViewById(R.id.Txtcontact);
setContentView(txtVersion);
setContentView(txtWarning);
setContentView(txtInstructions);
setContentView(txtContact);
}
}
Ok, solved it.... the problem was the setcontentview() method, deleted it and now it works