草庐IT

Android startActivity() 崩溃

coder 2023-12-19 原文

基本免责声明;总体而言,我是移动应用程序编程的新手,尤其是 android。

我有一个按钮,点击它会打开下一个 Activity :

bCustom.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
        Intent i = new Intent(ctx, DiceCustomList.class);
        startActivity(i);
    }
});

(其中“private Context ctx = this;”因为在 onClick 中将“this”放在“ctx”所在的位置并没有获得上下文)

程序在当前 Activity 被遮盖之前崩溃(虽然我不确定转换如何影响这一点)。在注释掉几乎所有内容之后,这是它调用的 Activity :

public class DiceCustomList extends ListActivity {
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.custom_list);
    }
}

和 custom_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:text="@string/rollText"
        android:id="@+id/textRoll2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="11pt"
        android:gravity="center"/>
    <ListView android:layout_height="wrap_content"
        android:id="@+id/listView1"
        android:layout_width="fill_parent"/>
</LinearLayout>

我认为问题出在按钮代码上,但我似乎无法比这更接近答案。

编辑:android list 文件确实有:

<activity android:name=".DiceCustomList"></activity>

编辑 2:啊,在最终找到 Eclipse 隐藏堆栈跟踪的位置后,它告诉我:“您的内容必须有一个 ListView,其 id 属性为‘android.R.id.list’”,这实际上意味着“@+id/android:列表”。嗯,这很有趣。 (Edit3:我的意思是,这就是答案。感谢提示。)

最佳答案

检查以确保 DiceCustomList Activity 在 list XML 文件中有一个条目。

关于Android startActivity() 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5011264/

有关Android startActivity() 崩溃的更多相关文章

  1. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  2. Ruby Readline 在向上箭头上使控制台崩溃 - 2

    当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby​​安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少

  3. ruby - 在多个线程中引用类方法会导致自动加载循环依赖崩溃 - 2

    代码:threads=[]Thread.abort_on_exception=truebegin#throwexceptionsinthreadssowecanseethemthreadseputs"EXCEPTION:#{e.inspect}"puts"MESSAGE:#{e.message}"end崩溃:.rvm/gems/ruby-2.1.3@req/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:478:inload_missing_constant':自动加载常量MyClass时检测到循环依赖稍加研究后,

  4. ruby - 执行过期异常使 Ruby 线程崩溃,但处理了 Timeout::Error - 2

    任何人都可以解释为什么当对方法的调用看起来像这样时我可能会看到这个堆栈(由HTTParty::post请求引起):beginresponse=HTTParty::post(url,options)rescuelogger.warn("Couldnotpostto#{url}")rescueTimeout::Errorlogger.warn("Couldnotpostto#{url}:timeout")end堆栈:/usr/local/lib/ruby/1.8/timeout.rb:64:in`timeout'/usr/local/lib/ruby/1.8/net/protocol.rb

  5. ruby - vim 使用 AutoComplPop 插件崩溃 - 2

    我使用vim编辑ruby​​文件,但是当我输入“.”时它崩溃了。我发现它是由AutoComplPop插件引起的。我该怎么办? 最佳答案 我找到了一种使用autocomplpop和filetype=ruby来防止vim崩溃的方法。将以下行放入您的.vimrcletg:acp_behaviorRubyOmniMethodLength=-1这将防止在您键入“.”时触发autocomplpop。(期间)这不是解决办法。(我不是vim插件程序员)祝你好运! 关于ruby-vim使用AutoComp

  6. ruby-on-rails - 自动加载路径和嵌套服务类在 Ruby 中崩溃 - 2

    我在Rails5项目的app/services文件夹下有多个加载/需要类的问题,我开始放弃这个问题。首先要明确的是,services/是我在整个项目中使用的简单PORO类,用于从Controller、模型等中抽象出大部分业务逻辑。树看起来像这样app/services/my_service/base.rbfunny_name.rbmy_service.rbmodels/funny_name.rb失败#1首先,当我尝试使用MyService.const_get('FunnyName')时,它从我的模型目录中获取了FunnyName。当我直接执行MyService::FunnyName时,

  7. ruby - unicorn 与 Ruby 2.4.1 导致奇怪的崩溃 - 2

    我正在从Ruby2.3.1升级到Ruby2.4.1,这样做之后,Unicorn似乎与新版本不兼容。我收到以下错误。我正在使用Unicorn5.1.0并尝试过Unicorn5.3.1无济于事。我是否需要使用不同的库而不是XCode工具进行编译?我在使用foremanstart和Procfile启动服务器后立即收到错误:webpack:bin/webpack-dev-servergulp:gulpredis:./scripts/start_redis_server.shsidekiq:bundleexecsidekiq-Cconfig/sidekiq.ymlannotations_serv

  8. ruby - Heroku 应用程序崩溃并显示 'libruby.so.1.9: cannot open shared object file' - 2

    这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭10年前。我在部署这个应用程序时从未遇到过问题,但我刚刚推送,现在我遇到了这个奇怪的错误,它在堆栈中足够深,甚至没有被发送到Airbrake。我觉得这可能是Heroku的问题,可能与https://status.heroku.com/incidents/450有关。?你怎么看?2012-10-14T08:40:31+00:00heroku[web.1]:State

  9. ruby - 带有 ruby​​ 1.9.3 的 Heroku 导致许多不同的崩溃 - 2

    我使用Gemfile中的新gem重新部署我的heroku应用程序,它在启动时崩溃了/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in`require':libruby.so.1.9:cannotopensharedobjectfile:Nosuchfileordirectory-/app/vendor/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.so(LoadError)无论我部

  10. ruby-on-rails - ruby 2.0.0p247 的段错误导致 Rails 服务器崩溃 - 2

    在OSXMavericks1.9上运行Rails4.0、Ruby2.0.0p247我遇到了一个我今天从未遇到过但我不理解的错误。当试图在我的项目中启动我的Rails服务器时,服务器崩溃了。我确实尝试重新安装和重新编译一次,成功但在成功运行服务器两次后,它再次开始崩溃。知道是什么原因造成的吗?admins-air:rengaadmin$railss/Users/admin/.rvm/gems/ruby-2.0.0-p247/gems/json-1.8.1/lib/json/ext/parser.bundle:[BUG]Segmentationfaultruby2.0.0p247(2013

随机推荐