- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我运行我的代码时,它可以工作几秒钟并自动关闭。它显示消息不幸的是您的应用已关闭。在我添加了带有按钮的布局之后,这开始发生。
这是我的原木猫
07-21 04:41:14.320: E/AndroidRuntime(1764): FATAL EXCEPTION: main
07-21 04:41:14.320: E/AndroidRuntime(1764): Process: com.example.adaderana, PID: 1764
07-21 04:41:14.320: E/AndroidRuntime(1764): java.lang.NullPointerException
07-21 04:41:14.320: E/AndroidRuntime(1764): at com.example.adaderana.MainActivity$DownloadJSON.onPostExecute(MainActivity.java:140)
07-21 04:41:14.320: E/AndroidRuntime(1764): at com.example.adaderana.MainActivity$DownloadJSON.onPostExecute(MainActivity.java:1)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.os.AsyncTask.finish(AsyncTask.java:632)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.os.AsyncTask.access$600(AsyncTask.java:177)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.os.Handler.dispatchMessage(Handler.java:102)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.os.Looper.loop(Looper.java:137)
07-21 04:41:14.320: E/AndroidRuntime(1764): at android.app.ActivityThread.main(ActivityThread.java:4998)
07-21 04:41:14.320: E/AndroidRuntime(1764): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 04:41:14.320: E/AndroidRuntime(1764): at java.lang.reflect.Method.invoke(Method.java:515)
07-21 04:41:14.320: E/AndroidRuntime(1764): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-21 04:41:14.320: E/AndroidRuntime(1764): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
07-21 04:41:14.320: E/AndroidRuntime(1764): at dalvik.system.NativeStart.main(Native Method)
07-21 04:41:14.350: W/ActivityManager(371): Force finishing activity com.example.adaderana/.MainActivity
07-21 04:41:14.390: D/gralloc(51): Registering a buffer in the process that created it. This may cause memory ordering problems.
07-21 04:41:14.390: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.390: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.390: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.390: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.390: E/SurfaceFlinger(51): glCheckFramebufferStatusOES error 1717000432
07-21 04:41:14.390: E/SurfaceFlinger(51): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
07-21 04:41:14.400: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.400: E/libEGL(51): called unimplemented OpenGL ES API
07-21 04:41:14.400: W/WindowManager(371): Screenshot failure taking screenshot for (246x410) to layer 21015
07-21 04:41:14.710: I/Choreographer(371): Skipped 56 frames! The application may be doing too much work on its main thread.
07-21 04:41:14.990: W/ActivityManager(371): Activity pause timeout for ActivityRecord{b3edf2f8 u0 com.example.adaderana/.MainActivity t16 f}
07-21 04:41:15.010: I/Choreographer(371): Skipped 38 frames! The application may be doing too much work on its main thread.
07-21 04:41:15.370: I/Choreographer(371): Skipped 37 frames! The application may be doing too much work on its main thread.
07-21 04:41:15.420: I/Choreographer(371): Skipped 109 frames! The application may be doing too much work on its main thread.
07-21 04:41:15.430: I/Choreographer(534): Skipped 75 frames! The application may be doing too much work on its main thread.
07-21 04:41:18.560: I/Choreographer(371): Skipped 30 frames! The application may be doing too much work on its main thread.
07-21 04:41:18.780: I/Choreographer(371): Skipped 54 frames! The application may be doing too much work on its main thread.
07-21 04:41:19.080: I/Choreographer(371): Skipped 40 frames! The application may be doing too much work on its main thread.
07-21 04:41:19.320: I/Choreographer(371): Skipped 58 frames! The application may be doing too much work on its main thread.
07-21 04:41:19.520: I/Choreographer(371): Skipped 52 frames! The application may be doing too much work on its main thread.
07-21 04:41:29.710: W/ActivityManager(371): Activity destroy timeout for ActivityRecord{b3edf2f8 u0 com.example.adaderana/.MainActivity t16 f}
package com.example.adaderana;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
public class MainActivity extends Activity {
// Declare Variables
JSONObject jsonobject;
JSONArray jsonarray;
ListView listview;
ListViewAdapter adapter;
ProgressDialog mProgressDialog;
ArrayList<HashMap<String, String>> arraylist;
static String TITLE = "title";
static String AUTHOR = "author";
static String THUMBNAIL = "thumbnail";
static String CONTENTS = "contents";
static String IMAGE = "image";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the view from list_main.xml
setContentView(R.layout.button);
Button b = (Button) findViewById(R.id.button2);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Video.class);
startActivityForResult(myIntent, 0);
// new DownloadJSON().execute();
}
});
Button a = (Button) findViewById(R.id.button1);
a.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DownloadJSON().execute();
}
});
// Execute DownloadJSON AsyncTask
// new DownloadJSON().execute();
}
// DownloadJSON AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
// Create a progressdialog
mProgressDialog = new ProgressDialog(MainActivity.this);
// Set progressdialog title
mProgressDialog.setTitle("Derana News");
// Set progressdialog message
mProgressDialog.setMessage("Loading...");
mProgressDialog.setIndeterminate(false);
// Show progressdialog
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
// Create an array
arraylist = new ArrayList<HashMap<String, String>>();
// Retrieve JSON Objects from the given URL address
jsonobject = JSONfunctions
.getJSONfromURL("http://www.adaderana.mobi/apple/ipad.php?q=topcat&cat=36");
try {
// Locate the array name in JSON
jsonarray = jsonobject.getJSONArray("TopNewsGivenCat");
for (int i = 0; i < jsonarray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
jsonobject = jsonarray.getJSONObject(i);
// Retrive JSON Objects
map.put("title", jsonobject.getString("title"));
map.put("author", jsonobject.getString("author"));
map.put("thumbnail", jsonobject.getString("thumbnail"));
map.put("contents", jsonobject.getString("contents"));
map.put("image", jsonobject.getString("image"));
// Set the JSON Objects into the array
arraylist.add(map);
}
} catch (JSONException e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
listview = (ListView) findViewById(R.id.listview);
// Pass the results into ListViewAdapter.java
adapter = new ListViewAdapter(MainActivity.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
// Close the progressdialog
mProgressDialog.dismiss();
}
}
}
最佳答案
您正在将按钮布局设置为内容setContentView(R.layout.button);
没有listview作为您的评论说// Locate the listview in listview_main.xml
那么findViewById(R.id.listview);
如何获得listview?
请修复您的xml,并在onCreate()上使用listview = (ListView) findViewById(R.id.listview);
。
关于android - 致命异常: main Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24860969/
我的电脑正确配置了 SSH,我在尝试克隆存储库时遇到了这个错误: 我运行这个命令来克隆存储库 git clone ssh://git-codecommit.us-west-2.amazonaws.co
我试图下载android源代码。但是遇到了一个问题。 # repo init -u https://android.googlesource.com/platform/manifest fatal:
尝试运行我 4 年前开发的 Rails 4 项目,从那时起我一直在维护,我遇到了下一个错误,该错误在启动时卡住了应用程序: machine stack overflow in critical reg
这个问题在这里已经有了答案: psql: FATAL: role "postgres" does not exist (32 个答案) 关闭上个月。 我正在设置 Postgresql 以与 Rail
我正在创建新分支并尝试推送该分支(我尝试了以下命令): git push --all -u git push origin NewBranch 但在这两种情况下我都会收到此错误: Permission
我尝试克隆这个 repo 几次,但得到了同样的错误。是不是因为它太大而我的连接速度很慢? $ git clone https://git01.codeplex.com/typescript Cloni
我正在尝试使用 http://danielmiessler.com/study/git/#website 设置 git管理我的网站。 我已经到了指令的最后一步:git push website +ma
当我使用快速启动方法安装Eucalyptus云时,我看到安装失败。以后检查日志文件时,遇到以下错误。 最佳答案 错误消息是: Invalid gateway due to subnet/netmask
黄色, 我尝试按照以下步骤设置选项“在没有用户名和密码的情况下访问(推送到)Github”。 https://medium.com/@amanze.ogbonna/accessing-pushing-
我很难用 postgres 设置 django。 这是我的设置.py: DATABASES = { 'default': { 'ENGINE': 'django.db.back
当我尝试从实时实例服务器访问数据库时出现此错误。有谁知道原因吗? 最佳答案 可能是你的硬盘没有可用空间 关于PostgreSQL:致命:XX000:无法写入初始化文件,我们在Stack Overflo
我正在尝试连接到我的 PostgreSQL 服务器,但 psql 提示我没有有效的客户端证书。以下是我创建证书的方式: 自签名服务器证书: openssl req -new -text -nodes
我团队中的其他人创建了一个新的 git 分支,提交并推送到我们使用的常用远程。当我尝试检查这个分支时,我得到了这个: % git checkout 12382 fatal: Cannot switch
我正在尝试让 TravisCI 自动部署我的 Hakyll 静态站点,根据 this guide . 这是我的存储库的设置方式。我有我的源代码分支,其中包含我的 hakyll 和 Markdown 文
尝试提交时 git commit -a -m "Huge update" 我明白了 fatal: could not parse HEAD Error When Committing 看完fatal:
我想在我的 flutter 应用程序上使用 fcm,所以在创建 firebase 控制台并在我的 gradle 中安装了一些依赖项之后,如下所示: build.gradle:项目 dependenci
我是 GIT 的初学者,现在遇到了一个大问题。我在另一台 PC 上提交并推送了一些文件,现在在我的家用 PC 上,git 坏了。 请看下面: $ git status fatal: failed to
我想从 github 上克隆一个项目到我的电脑上 D:\Projects> git clone https://github.com/***/***.git 但是在下载的时候,出现了几个致命的错误:
所以我尝试使用以下命令获取opencv_contrib: $ git clone https://github.com/Itseez/opencv_contrib 这给了我以下错误: fatal: d
这是我在pod文件中使用的行 pod'SDWebImage','〜> 3.8' 以前是 pod'SDWebImage','〜> 3.7' 我尝试了以下 pod安装 pod更新和 pod更新'SDWeb
我是一名优秀的程序员,十分优秀!