- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个应用程序,上面有 fragment
和 image button
。问题是它在 5.0
及以上工作,但不低于 5.0。最低 sdk 版本为 17。
没有弄清楚这里有什么问题。我收到 2 个异常(exception)。
一个是 RuntimeException
for image button
。其次是 fab 选择器文件的 ResourceNotFoundException
。
日志:第一个异常(exception)——
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException: Binary XML file line #16:
错误膨胀类 ImageButton
第二个异常(exception)——
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton
在线:
View view = inflater.inflate(R.layout.fragment_main, container, false);
主要 fragment 。
主要 fragment :
public class MainFragment extends Fragment {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private CharSequence Titles[]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
private int Numboftabs =7;
private SlidingTabLayout tabs;
private Intent i;
public MainFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_main, container, false);
setupUI(view);
return view;
}
void setupUI(View view)
{
FrameLayout fab = (FrameLayout)view.findViewById(R.id.main_fab);
ImageButton imageButton = (ImageButton)view.findViewById(R.id.imgbtn_fab);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String day;
Boolean editMode = false;
if(tabs.getCurrentTab() == 0)
{
day = "Mon";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 1)
{
day = "Tue";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 2)
{
day = "Wed";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 3)
{
day = "Thu";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 4)
{
day = "Fri";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 5)
{
day = "Sat";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
else if(tabs.getCurrentTab() == 6)
{
day = "Sun";
i = new Intent(getActivity(),AddEventActivity.class);
i.putExtra("day",day);
i.putExtra("EditMode",editMode);
startActivity(i);
}
Log.d("tab",tabs.getCurrentTab() + "");
}
});
mAdapter = new TabsPagerAdapter(getFragmentManager(),Titles,Numboftabs);
viewPager = (ViewPager)view.findViewById(R.id.pager);
viewPager.setAdapter(mAdapter);
tabs = (SlidingTabLayout)view.findViewById(R.id.tabs);
tabs.setDistributeEvenly(true);
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
@Override
public int getIndicatorColor(int position) {
return getResources().getColor(R.color.tab_scroll_color);
}
});
tabs.setViewPager(viewPager);
}
}
工厂选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="?attr/colorAccent" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="oval">
<solid android:color="?attr/colorAccent" />
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="?attr/colorAccent" />
</shape>
</item>
</selector>
主要 fragment :
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" tools:context="com.adgatemedia.offerwallsdk.fragments.MainFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<utils.SlidingTabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="2dp"
android:background="?attr/colorPrimary"
android:layout_alignParentTop="true" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="@+id/tabs" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end">
<include layout="@layout/myfab"/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
工厂:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_fab"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="bottom|end">
<View
android:id="@+id/myfab_shadow"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_gravity="center"
android:background="@drawable/fab_shadow"
android:focusable="false" />
<ImageButton
android:id="@+id/imgbtn_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/fab_selector"
android:cropToPadding="true"
android:padding="10dp"
android:src="@drawable/ic_add_white_36dp"
android:stateListAnimator="@animator/fab_elevation_selector" />
</FrameLayout>
完整的堆栈跟踪:
FATAL EXCEPTION: main
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:5114)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/fab_selector.xml from drawable resource ID #0x7f020081
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1953)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.View.<init>(View.java:3330)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.widget.ImageView.<init>(ImageView.java:114)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.widget.ImageButton.<init>(ImageButton.java:87)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:59)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:55)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:171)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:5114)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.TypedArray.getColor(TypedArray.java:326)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:967)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)
你能告诉我这里出了什么问题吗?
最佳答案
这个异常
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2 02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.TypedArray.getColor(TypedArray.java:326) 02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:967) 02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)
得出这一行 <solid android:color="?attr/colorAccent" />
的结论在 fab_selector
是罪魁祸首。试试改color
至 HEX value
然后测试。
希望这对您有所帮助。
关于android - 错误膨胀类 ImageButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35448999/
我需要使用view.getWidth(),但我不能,因为我还没有膨胀 View 。在使用 view.getWidth() 之前如何膨胀 View ? MainActivity 类: p
这个问题很难尝试和表述,但我会尽力而为。 基本上,我有一个应用程序,我想将代码拆分得更多。为了尝试解释这一点,我将举一个我的屏幕示例。 在我的主屏幕上,我有一个标题、用户详细信息、余额、下一个账单详细
我有一个 TableLayout,我在其中动态添加行,一开始是空的,我想在用户单击它时在该行中加载一个 xml。 我已经给行赋值了OnClick方法,但是不知道在onclick方法中进入时如何加载xm
我使用的是 C++ 中的 libcurl 库,这是一个相当大的库(.lib 文件大约 2MB),项目是用 CURL_STATICLIB 编译的 至于现在我只有一个 .cpp 文件,其中包含 heade
背景: 我正在努力使一堆 PNG 尽可能小。我正在使用诸如 PngOut、PngCrush 和 OptiPng 之类的工具。 问题: 我遇到了一个大小为 1434 KB 但只有 230 x 230 像
我一直在努力找出我的应用程序使用的内存不断增长的原因,直到在 heroku 上的生产中它失败并下降。 经过一些相当广泛的研究,使用 Top 观察 RSIZE 在本地增长并使用 Oink 尝试查明我只是
我有一个使用 C++ 版本的 zlibs deflate 压缩的数据 ArrayBuffer(使用默认值)。由于没有服务器,我现在需要在客户端中增加这些数据。我已经使用 C++ 中的默认 inflat
我的代码有问题: @Override public View getView(int position, View convertView, ViewGroup parent) {
我有一个 fragment ,我像下面一样对其进行膨胀,但它给出了运行时错误: public View onCreateView(LayoutInflater inflater, ViewGroup
我正在学习 Fragment,并且我是通过在 Fragment 中使用 FB Login 来学习的。但我不断收到异常 Error inflateing class com.facebook.login
第一种方法: LinearLayout parent = ...; View child = LayoutInflator.inflate(context, parent, true); 第二种方法:
我刚刚完成了一个站点构建,在该站点构建中,我们必须将文件提供给第 3 方以与他们的系统集成。构建必须是独立的,因为会有多方部署它们,能力水平各不相同。 我遇到的问题是,在下载我的 Javascript
我正在寻找一种方法来“扩充”Android XML 布局,这在编译时是未知的。我已经搜索了几个小时,总能找到答案,这是不可能的,因为 LayoutInflater 不能使用简单的 XML 文件。好的,
我有一个从 Faragment 扩展而来的类,叫做 Agenda。它的布局有一个 listView,但是当这个类返回到主 Activity 时,我得到了一个错误。这是错误和代码: > 03-11 13
我的应用程序一启动就崩溃了。我收到以下错误: android.view.InflateException: Binary XML file line #34: Error inflating clas
我想膨胀 R.id.catText,但如果我自己膨胀它,它永远不会显示。如果我inflate R.id.assets(容器),那么两个元素都会正常显示。我只是不想要容器。如何在不膨胀 R.id.ass
我尝试创建自定义 ViewGroup 类,但是当我使用方法 findViewById() 时它返回 null,但展开 View 是可以的。 代码是: public class HorizontalLi
我正在尝试创建一个在屏幕上滑动的 textView,但它会产生错误,但我不知道为什么。这是我的 xml: 还有我的 Activity 课: package com.exampl
我正在构建一个应用程序,我在其中使用了 glomadrain 的动画切换按钮。完成编码后出现以下错误: at com.android.internal.os.ZygoteInit.main(Zygot
我只是想按照 android dev 上的示例代码来膨胀 Activity 中的 fragment 。我有一个更复杂的项目正在工作,但我遇到了与这里的简单项目相同的错误。谁能指出我正确的方向? 扩展
我是一名优秀的程序员,十分优秀!