Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get parent id on Android?
    primarykey
    data
    text
    <p>I've tried to get parent id of RadioButton (id of RadioGroup) by</p> <pre><code>RadioGroup rg = (RadioGroup) arg0.getParent(); </code></pre> <p>but it failed. Following construction</p> <pre><code>RadioGroup rg = (RadioGroup) findViewById(R.id.radiogr); </code></pre> <p>works well. How can I get parent id at runtime?</p> <p>fails with these logs:</p> <pre><code>12-26 17:11:05.205: E/AndroidRuntime(912): FATAL EXCEPTION: main 12-26 17:11:05.205: E/AndroidRuntime(912): java.lang.ClassCastException: android.widget.LinearLayout 12-26 17:11:05.205: E/AndroidRuntime(912): at com.letmedraw.shopcart.ShopCartActivity.onCheckedChanged(ShopCartActivity.java:96) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:172) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.RadioGroup.access$600(RadioGroup.java:52) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.RadioGroup$CheckedStateTracker.onCheckedChanged(RadioGroup.java:342) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.CompoundButton.setChecked(CompoundButton.java:127) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.CompoundButton.toggle(CompoundButton.java:86) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.RadioButton.toggle(RadioButton.java:69) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.widget.CompoundButton.performClick(CompoundButton.java:98) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.view.View$PerformClick.run(View.java:8816) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.os.Handler.handleCallback(Handler.java:587) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.os.Handler.dispatchMessage(Handler.java:92) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.os.Looper.loop(Looper.java:123) 12-26 17:11:05.205: E/AndroidRuntime(912): at android.app.ActivityThread.main(ActivityThread.java:4627) 12-26 17:11:05.205: E/AndroidRuntime(912): at java.lang.reflect.Method.invokeNative(Native Method) 12-26 17:11:05.205: E/AndroidRuntime(912): at java.lang.reflect.Method.invoke(Method.java:521) 12-26 17:11:05.205: E/AndroidRuntime(912): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 12-26 17:11:05.205: E/AndroidRuntime(912): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 12-26 17:11:05.205: E/AndroidRuntime(912): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload