<分区> 分区>
09-05 07:57:28.570: E/AndroidRuntime(1138): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.fragment_one.f_one: make sure class name exists, is public, and has an empty constructor that is public
09-05 08:57:03.058: E/AndroidRuntime(1477): FATAL EXCEPTION: main
09-05 08:57:03.058: E/AndroidRuntime(1477): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fragments_one/com.example.fragments_one.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.os.Handler.dispatchMessage(Handler.java:99)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.os.Looper.loop(Looper.java:137)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-05 08:57:03.058: E/AndroidRuntime(1477): at java.lang.reflect.Method.invokeNative(Native Method)
09-05 08:57:03.058: E/AndroidRuntime(1477): at java.lang.reflect.Method.invoke(Method.java:511)
09-05 08:57:03.058: E/AndroidRuntime(1477): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-05 08:57:03.058: E/AndroidRuntime(1477): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-05 08:57:03.058: E/AndroidRuntime(1477): at dalvik.system.NativeStart.main(Native Method)
09-05 08:57:03.058: E/AndroidRuntime(1477): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
09-05 08:57:03.058: E/AndroidRuntime(1477): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.Activity.setContentView(Activity.java:1835)
09-05 08:57:03.058: E/AndroidRuntime(1477): at com.example.fragments_one.MainActivity.onCreate(MainActivity.java:12)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.Activity.performCreate(Activity.java:4465)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-05 08:57:03.058: E/AndroidRuntime(1477): ... 11 more
09-05 08:57:03.058: E/AndroidRuntime(1477): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.fragment_one.f_one: make sure class name exists, is public, and has an empty constructor that is public
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.support.v4.app.Fragment.instantiate(Fragment.java:395)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.support.v4.app.Fragment.instantiate(Fragment.java:363)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:264)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
09-05 08:57:03.058: E/AndroidRuntime(1477): ... 21 more
09-05 08:57:03.058: E/AndroidRuntime(1477): Caused by: java.lang.ClassNotFoundException: com.example.fragment_one.f_one
09-05 08:57:03.058: E/AndroidRuntime(1477): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
09-05 08:57:03.058: E/AndroidRuntime(1477): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-05 08:57:03.058: E/AndroidRuntime(1477): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-05 08:57:03.058: E/AndroidRuntime(1477): at android.support.v4.app.Fragment.instantiate(Fragment.java:385)
09-05 08:57:03.058: E/AndroidRuntime(1477): ... 24 more
主要 Activity
package com.example.fragments_one;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/f_one"
android:name="com.example.fragment_one.f_one"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
<fragment
android:id="@+id/f_two"
android:name="com.example.fragment_one.f_two"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
fragment 布局
1.f_one.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00FF00"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is fragment #1"
android:textColor="#000000"
android:textSize="25sp" />
</LinearLayout>
f_two.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFE00"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is fragment #2"
android:textColor="#000000"
android:textSize="25sp" />
</LinearLayout>
我的 fragment 类
package com.example.fragments_one;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class f_one extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// ---Inflate the layout for this fragment---
return inflater.inflate(R.layout.f_one, container, false);
}
}
package com.example.fragments_one;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class f_two extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// ---Inflate the layout for this fragment---
return inflater.inflate(R.layout.f_two, container, false);
}
}
是否可以为特定(或所有)项目使用多个布局?例如,我有几个项目,我想对其应用两种不同的布局。一个是绿色的,一个是蓝色的(但是)。我想将它们编译到我的输出目录中的两个不同文件夹中(例如v1和v2)。我一直在玩弄规则和编译block,但我不知道这是怎么回事。因为,每个项目在编译过程中只编译一次,我不能告诉nanoc第一次用layout1编译,第二次用layout2编译。我试过这样的东西,但它导致输出文件损坏。compile'*'doifitem.binary?#don’tfilterbinaryitemselsefilter:erblayout'layout1'layout'layout2'
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我想为网站的管理和公共(public)部分设置一对样式指南。每个都需要自己的布局,其中包含静态html和调用erbpartials的混合(因此静态页面不会削减它)。我不需要Controller来为这些页面提供服务,而且我不希望有效的仅开发内容使其余代码困惑。这让我想知道是否有一种方法可以直接呈现布局。免责声明:我明白这不是我应该经常/永远做的事情,而且我知道有很多争论可以解释为什么这是一个坏主意。我对这是否可能感兴趣。有没有办法让我直接从routes.rb渲染布局而不通过Controller? 最佳答案 出于某种奇怪的原因,我想暂时
这个问题在这里已经有了答案:differentlayoutforsign_inactionindevise(8个答案)关闭7年前。如何更改设计Controller中的布局?
我有request.env['http_host']在本地主机上工作,但在heroku的布局页面中引用时会导致错误。此请求在View中工作并显示正确的基本url,但是当我将代码移动到布局时它会导致错误。注意-我正在使用它来为html电子邮件中的图像构建绝对url。收到错误:ActionView::Template::Error(undefinedmethod`env'fornil:NilClass): 最佳答案 如果你想要没有端口的主机,只需使用:request.host编辑:糟糕,我刚刚注意到您正在使用View中的代码。我不知道它
我对RubyGUI设计做了很多研究,这似乎是Ruby倾向于落后的领域。我探索了MonkeyBars、wxRuby、fxRuby、Shoes等选项,只是想从Ruby社区获得一些意见。虽然它们绝对可用,但每一个的开发似乎都在下降。我在任何(减去fxRuby书)上都找不到大量有用的文档或用户基础。我只是想制作一个简单的GUI,所以我真的不想花费数百小时来学习更复杂的工具的复杂性或尝试使用甚至不再开发的东西(鞋子是应用程序的类型我正在寻找,但它有很多问题并且没有得到积极开发。)在所有选项中,你们会推荐哪个选项是最快的,并且仍然具有某种开发基础?谢谢! 最佳答案
我正在覆盖设计注册Controller的创建操作。我有两种注册表格,个人或公司,公司有一个名为company_form的字段设置为true以区分这两种表格。在表单验证后,我希望呈现正确的表单(以前无论我使用什么表单,它都会返回默认表单)。我遇到了一个问题,即只渲染了部分(很明显,因为我只渲染了部分),但我还需要渲染布局/应用程序文件。classRegistrationsControllerifresource.company_formrenderpartial:'shared/company_signup_form'elserenderpartial:'/shared/individu
我正在学习michaelharltrails教程,但出现此错误Missingtemplatelayouts/mailerwith{:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:raw,:erb,:html,:builder,:ruby,:coffee,:jbuilder]}.Searchedin:*"/home/ubuntu/workspace/app/views"预览账户激活时这是我的user_mailer.rbclassUserMailer错误突出显示了mailto:user.email,subject:"A
tl;dr:在Sinatra中是否有一种干净的嵌套布局方式?对于我网站上的所有页面,我有一个通用的layout.erb,它呈现页眉、页脚和其他一些位。对于这些页面的一个子集,我想使用内部布局,除了那些公共(public)位之外,它还呈现左侧菜单。全局erb:pageTemplate执行layout.erb,其中yield执行pageTemplate在子集中erb:pageTemplate执行layout.erb,其中yield执行specificLayout.erb,其中yield执行pageTemplate。有道理吗?我对单独的类、before语句和任何其他ruby魔法持开放态度
我需要消息在项目中有不同的布局,是否可以在Rails中做这样的事情?ClassMessages::New谢谢 最佳答案 这对你有帮助classMessagesController 关于ruby-on-rails-在Rails中是否可以动态加载类布局?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1274999/