Android - Throwing fatal exception where it wasn't before - android

Explanation at the end of the code
Java:
void GetNextQuestion()
{
QuestNum++;
/// ERROR ON VERY NEXT LINE
ProgressBar pbar = (ProgressBar)this.findViewById(R.id.progressBar2);
TextView tvSection = (TextView)this.findViewById(R.id.section);
TextView tvSubsection = (TextView)this.findViewById(R.id.subsection);
TextView tvQuest = (TextView)this.findViewById(R.id.quest);
if(QuestNum > 0 && QuestNum < 180)
{
tvSection.setText(R.string.s1);
tvSubsection.setText(R.string.ss1);
spin.setSecondaryProgress((int)((QuestNum/180) * 1000));
}
if(QuestNum > 179 && QuestNum < 285)
{
tvSection.setText(R.string.s2);
tvSubsection.setText(R.string.ss2);
}
}
XML:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="#+id/icon"
android:layout_width="57dp"
android:layout_height="54dp"
android:src="#drawable/devil" />
<TextView
android:id="#+id/section"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/icon"
android:text="#string/nunca"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible" />
<TextView
android:id="#+id/subsection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/section"
android:layout_alignParentRight="true"
android:layout_below="#+id/icon"
android:text="#string/nunca"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="#+id/help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/helpico" />
<ImageView
android:id="#+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/subsection"
android:layout_alignParentRight="true"
android:src="#drawable/exitico" />
<TextView
android:id="#+id/haveyou"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/subsection"
android:layout_marginTop="18dp"
android:text="#string/nunca"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/quest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/load"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/butyes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_above="#+id/progressBar2"
android:layout_marginBottom="30dp"
android:text="Yes" />
<Button
android:id="#+id/butno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_above="#+id/progressBar2"
android:layout_marginBottom="30dp"
android:text="No" />
<ProgressBar
android:id="#+id/progressBar2"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:max="1000"
android:progress="0"/>
</RelativeLayout>
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="a14ffb06b21e68e"
app:loadAdOnCreate="true" >
</com.google.ads.AdView>
</LinearLayout>
Error:
E/AndroidRuntime(20649): FATAL EXCEPTION: main
E/AndroidRuntime(20649): java.lang.ClassCastException: android.widget.Button
at com.ndai.ptest.a1000test.GetNextQuestion(a1000test.java:146)
at com.ndai.ptest.a1000test$QuestAnsTask.onPostExecute(a1000test.java:3319)
at com.ndai.ptest.a1000test$QuestAnsTask.onPostExecute(a1000test.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
here is what i don't understand...it is giving me a casting error...i am casting a progressbar tp a progressbar...am i just missing a typo or something...i just need an extra set of eyes on this one
EDIT:
I did however not receive this error until after i rearranged stuff on the xml

I FIXED IT
I was reading how other people have been having the same issues when not using the GUI to change the layout...so i followed these steps
Fix the project (right click project, got android tools then the only option that says fix)
Delete R.java
Fix The Project again

What was happening is that eclipse (Or what ever you use) didn't want to update R file with the right data, meaning that the id of your progress bar or what ever it was casting was being mixed up with one of the buttons, nice little bug for ya.

Related

Android layout inflate exception in fragments

my app is suffering from crash whenever i press back key. basically i have 4 fragments but app crashes only when it comes back on my first fragment.
FATAL EXCEPTION: main
Process: , PID: 5835
android.view.InflateException: Binary XML file line #16: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at NewBookingFragment.onCreateView(NewBookingFragment.java:174)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:979)
at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1670)
at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:586)
at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:188)
at HomeActivity.onBackPressed(HomeActivity.java:161)
at android.app.Activity.onKeyUp(Activity.java:2576)
at android.view.KeyEvent.dispatch(KeyEvent.java:3171)
at android.app.Activity.dispatchKeyEvent(Activity.java:2831)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2429)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4580)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4535)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4199)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4256)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4232)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4419)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2480)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2074)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2065)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2457)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
Code-
#Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);//line 161
} else {
super.onBackPressed();
}
}
XML Code which is causing issue:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.app.myapp.HomeActivity"
>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
class="com.app.myapp.TouchableSupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<RelativeLayout
android:id="#+id/rlDriverProgress"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:background="#drawable/oval_progress"
android:padding="5dp"
>
<ProgressBar
android:id="#+id/getDriversProgress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/rlTimeRequired"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:background="#drawable/oval_progress"
android:padding="5dp"
android:gravity="center|center_vertical|center_horizontal"
>
<TextView
android:layout_width="25dp"
android:layout_height="wrap_content"
android:text="10"
android:textStyle="bold"
android:textSize="17sp"
android:gravity="center|center_horizontal|center_vertical"
android:textColor="#color/colorWhite"
android:id="#+id/tvNoOfMins"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MIN"
android:textStyle="bold"
android:textSize="15sp"
android:textColor="#color/colorWhite"
android:id="#+id/tvMinsHeading"
android:layout_below="#+id/tvNoOfMins"
/>
</RelativeLayout>
<LinearLayout
android:id="#+id/llSearchBar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="center_horizontal|top"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="100dp"
android:background="#drawable/bg_search_bar"
android:orientation="horizontal">
<ImageView
android:id="#+id/icSelectPickup"
android:layout_width="45dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:src="#drawable/icon_search"
/>
<EditText
android:id="#+id/tvPickupAddress"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="#null"
android:editable="false"
android:elegantTextHeight="false"
android:enabled="true"
android:focusable="true"
android:focusableInTouchMode="false"
android:text="Select Pickup Address"
android:textAlignment="gravity"
android:gravity="center_vertical|center_horizontal"
android:textSize="16sp"
android:textStyle="normal" />
</LinearLayout>
<!--android:textColor="#color/whiteTranparent" -->
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="faisal"
android:id="#+id/dummyCenterTV"
/>
<ImageView
android:id="#+id/pickupLocationPin"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/dummyCenterTV"
android:src="#drawable/carpin" />
<LinearLayout
android:id="#+id/layoutBookButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:orientation="vertical"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/btnPickLater"
android:layout_width="100dp"
android:layout_height="30dp"
android:text="Book Later"
android:layout_gravity="right|bottom"
android:layout_marginBottom="3dp"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:textSize="11dp"
android:background="#drawable/rc_primary_button"
android:textColor="#color/colorWhite"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/label_pick_now"
android:textAllCaps="false"
android:id="#+id/btnPickNow"
android:background="#color/colorAccent"
android:textColor="#color/colorWhite"
android:textSize="18dp"
android:textStyle="bold"
android:focusable="true"
android:clickable="true"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
i think map fragment section is the part crashing app. please have a look
Your error occurs here:
com.app.minicabscouk.HomeActivity.onBackPressed(HomeActivity.java:161)
That's line 161 of your HomeActivity. You'll need to post the code from that class if you still can't figure it out yourself.
Hey, turns out I made a mistake! Disregard my above answer, sorry.
Check out the first line here:
FATAL EXCEPTION: main Process: , PID: 5835 android.view.InflateException: Binary XML file line #16: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
That's your actual problem. Whichever fragment you're trying to create, there's a problem with the XML at line 16.

How to set the position of image

i am new in android , i am facing problem in setting the image position . i set image position in layout but when i check on device or emulator it changes position.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay_ring"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/backfull_a"
android:orientation="vertical" >
<ImageButton
android:id="#+id/id_ringButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="44dp"
android:layout_marginTop="16dp"
android:background="#android:color/transparent"
android:src="#drawable/button_ring" />
<ImageView
android:id="#+id/image_hand_lastACt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="#drawable/white" />
<ImageView
android:id="#+id/id_ring_finger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="144dp"
android:layout_marginRight="70dp"
android:layout_toLeftOf="#+id/id_ringButton"
android:src="#null" />
<ImageView
android:id="#+id/id_fingA_ring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/id_imgback"
android:layout_marginRight="21dp"
android:layout_marginTop="48dp"
android:src="#drawable/a_style_a" />
<ImageView
android:id="#+id/id_fingB_ring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/id_ringButton"
android:layout_marginRight="44dp"
android:layout_toLeftOf="#+id/id_fingA_ring"
android:src="#drawable/a_style_b" />
<ImageButton
android:id="#+id/id_next_ring"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/id_ringButton"
android:layout_alignTop="#+id/id_ring_finger"
android:layout_marginTop="46dp"
android:background="#android:color/transparent"
android:src="#drawable/aero_right" />
</RelativeLayout>
i tried but did not find proper solution . give some demo or link that is easily understandable .
android handset has many DPIs. so,you should not set the position too accurate.
You can use some relative description like toRightof / alignPerentRight etc.

RelativeLayout displays incorrect on real device

I have a question regarding Android RelativeLayout. My layout works perfectly on the emulator which is configured like a LG Nexus4 (screen, resolution). But if I run the app on my real Nexus4 it has serious errors and I don't know how to fix them.
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainMenuLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/zeekedLogo"
android:contentDescription="#string/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="24dp"
android:layout_marginRight="24dp"
android:src="#drawable/badge" />
<TextView
android:id="#+id/textButtonPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:text="#string/menu_play"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textButtonResume"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textButtonPlay"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="#string/menu_resume"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textLabelLevel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/zeekedLogo"
android:layout_centerHorizontal="true"
android:layout_marginBottom="54dp"
android:text="#string/menu_level"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textButtonSound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/zeekedLogo"
android:layout_marginLeft="24dp"
android:text="#string/menu_sound_on"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
Here are the screenshots of the same layout:
Emulator:
Nexus 4:
Thanks in advance!
After adding a background color to my relativelayout it worked on my Nexus4. It's all I did ... and I think it's strange. But at the end I'm happy that it works.

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 [duplicate]

This question already has an answer here:
Can't convert to dimension: type=0x1 when running app on Android 4.1
(1 answer)
Closed 9 years ago.
java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
at android.widget.ImageView.<init>(ImageView.java:137)
at android.widget.ImageButton.<init>(ImageButton.java:85)
at android.widget.ImageButton.<init>(ImageButton.java:81)
above is the error and below is the layout for the error. Everything i read says that the xml needs to have one parent layout, which mine does. what else could be wrong?
This is the layout for my main activity that gets launched when app launches
this is my min/target
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/app_name"
android:id="#+id/textView"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textSize="32sp"
android:layout_centerHorizontal="true"
android:background="#292929"
android:gravity="center_vertical|center_horizontal"
android:minHeight="#dimen/header_height" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/apply"
android:id="#+id/apply"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textSize="24sp"
android:background="#3fb0ff"
android:layout_weight="1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/wallpaper"
android:id="#+id/wallpapers"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textSize="24sp"
android:background="#3994d8"
android:layout_weight="1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/request_icons"
android:id="#+id/requesticons"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textSize="24sp"
android:background="#3376b4"
android:layout_weight="1" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/view_icons"
android:id="#+id/viewicons"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textSize="24sp"
android:background="#2c5f95"
android:layout_weight="1" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="false"
android:layout_alignParentStart="false"
android:measureWithLargestChild="false"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rate"
android:maxHeight="100dp"
android:background="#color/transparent"
android:src="#drawable/main_button_bottom_rate"
android:scaleType="fitXY"
android:layout_weight="1" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/gplus"
android:maxHeight="100dp"
android:src="#drawable/main_button_bottom_gplus"
android:layout_weight="1"
android:background="#color/transparent"
android:scaleType="fitXY" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/morework"
android:layout_weight="1"
android:background="#color/transparent"
android:maxHeight="100dp"
android:src="#drawable/main_button_bottom_morework"
android:scaleType="fitXY" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/contact"
android:background="#color/transparent"
android:layout_weight="1"
android:maxHeight="100dp"
android:src="#drawable/main_button_bottom_contact"
android:scaleType="fitXY" />
</LinearLayout>
</LinearLayout>
Your problem is with your ImageButtons... I don't think the XML inflater is happy with you using a weight and maxHeight at the same time... But it may be passing through because one of the attributes on your ImageButtons is for a higher API. Check the developer guide for all of them or remove them one by one until the crash disappears. It seems that all your ImageButtons are mostly identical, so I'd take that down to one for testing as well...
public int getDimensionPixelSize(int index, int defValue) {
index *= AssetManager.STYLE_NUM_ENTRIES;
final int[] data = mData;
final int type = data[index+AssetManager.STYLE_TYPE];
if (type == TypedValue.TYPE_NULL) {
return defValue;
} else if (type == TypedValue.TYPE_DIMENSION) {
return TypedValue.complexToDimensionPixelSize(
data[index+AssetManager.STYLE_DATA], mResources.mMetrics);
}
throw new UnsupportedOperationException("Can't convert to dimension: type=0x" // Line 463 of TypedArray.java
+ Integer.toHexString(type));
}

How can I add an extended TableLayout to make sure it is at the bottom

I am having some issues with a custom layout (ToDoView is extending TableLayout), and I do not know how to make sure it is under everything else (by everything else, I mean the EditText, and the Buttons).
As of right now, my app crashes with:
12-18 07:11:13.886: E/AndroidRuntime(3228):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.parrishb.todo/com.parrishb.todo.ToDoActivity}:
android.view.InflateException: Binary XML file line #44: Error
inflating class com.parrishb.todo.ToDoView
Here is the xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ToDoActivity" >
<EditText
android:id="#+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:contentDescription="#string/addItemContentDescription"
android:hint="#string/addItemHint" />
<Button
android:id="#+id/pickDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/myEditText"
android:text="Change the Date" />
<Button
android:id="#+id/pickTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/myEditText"
android:layout_toRightOf="#id/pickDate"
android:text="Change the Time" />
<DatePicker
android:id="#+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TimePicker
android:id="#+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.parrishb.todo.ToDoView
android:id="#+id/tdv"
class="com.parrishb.todo.ToDoView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/datePicker"
/>
</RelativeLayout>
Any help would be great!
I realized that in my ToDoView class, I was missing the constructor:
public ToDoView(Context c, AtrributeSet as){
super(c, as);
//...
}
Found at https://stackoverflow.com/a/3739853/1888585

Categories

Resources