什么都看不了任务栏不显示网络连接没有连接,请问怎么

小白在做Android新闻端用json获取网页数据出现如下图的报错不知道怎么改!求告知怎么改!可以看这个http://ask.csdn.net/questions/232048privateHandl
在做Android新闻端 用json获取网页数据 出现如下图的报错 不知道怎么改
!求告知 怎么改!可以看这个 private Handler getNewsHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
String jsonData = (String) msg.
System.out.println(jsonData);
JSONArray jsonArray = new JSONArray(jsonData);
for (int i=0;i&jsonArray.length();i++){
JSONObject object = jsonArray.getJSONObject(i);
String id = object.getString(""id"");
String title = object.getString(""title"");
String excerpt = object.getString(""excerpt"");
String date = object.getString(""date"");
String comment_count = object.getString(""comment_count"");//
String custom_fields = object.getString(""custom_fields"");
String thumb_value_URL = object.getString(""thumb_value_URL"");
System.out.println(""title = "" +title);
/*System.out.println(""thumb_value = "" +thumb_value);*/
newsList.add(new News(title date comment_count thumb_value_URL));
adapter.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lvNews = (ListView) findViewById(R.id.lvNews);
newsList = new ArrayList&News&();
adapter = new NewsAdapter(this newsList);
lvNews.setAdapter(adapter);
lvNews.setOnItemClickListener(this);
HttpUtils.getNewsJSON(GET_NEWS_URL getNewsHandler);
public void onItemClick(AdapterView&?& arg0 View arg1 int position long arg3) {
News news = newsList.get(position);
Intent intent = new Intent(this BrowseNewsActivity.class);
intent.putExtra(""Excerpt"" 11);
startActivity(intent);
}}public class News {private S//
private S//
private String comment_
private String thumb_//
private String custom_public News(String title String date String comment_count String thumb_value ){
setTitle(title);//
setExcerpt(excerpt);
setDate(date);//
setId(id);
setComment_count(comment_count);//
setCustom_fields(custom_fields);
setThumb_value(thumb_value);}public String getComment_count() {
return comment_}public void setComment_count(String comment_count) {
ment_count = comment_}public String getTitle() {}public void setTitle(String title) {
this.title =}public String getDate() {}public void setDate(String date) {
this.date =}public String getThumb_value() {
return thumb_}public void setThumb_value(String thumb_value) {
this.thumb_value = thumb_}} public class NewsAdapter extends BaseAdapter {
private List&News& newsL
public NewsAdapter(Context context List&News& newsList){
this.context =
this.newsList = newsL
public int getCount() {
return newsList.size();
public News getItem(int position) {
return newsList.get(position);
public long getItemId(int position) {
public View getView(int position View convertView ViewGroup parent) {
if (convertView == null){
convertView = LayoutInflater.from(context).inflate(R.layout.news_item null);
TextView Title = (TextView) convertView.findViewById(R.id.Title);//
TextView excerpt = (TextView) convertView.findViewById(R.id.excerpt);
TextView date = (TextView) convertView.findViewById(R.id.date);
TextView comment_count = (TextView)convertView.findViewById(ment_count);
ImageView thumb_value_URL = (ImageView) convertView.findViewById(R.id.thumb_value);
News news = newsList.get(position);
Title.setText(news.getTitle());//
excerpt.setText(news.getExcerpt());
date.setText(news.getDate());
comment_count.setText(news.getComment_count());//
String custom_fields = news.getCustom_fields();
HttpUtils.setPicBitmap(thumb_valuethumb_value_URL);*/
return convertV
String jsonData = (String) msg.
System.out.println(jsonData);
JSONArray jsonArray = new JSONArray(jsonData);
日志里面说37行有问题,我觉得也是,给的是JSONObject ,而你将之转换成JSONArray,会出现这种错误
解决方案二:
首先,这个不是报错,这是警告。警告不影响程序运行。你需要重新截个图
解决方案三:
你参考这个看看,org.json.JSON.typeMismatch(JSON.java:111)看到这句话的意思就是类型错配,简单的来说就是:获取给的字符串是JSONArray,而你将之转换成JSONObject,或者反过来就是给的是JSONObject ,而你将之转换成JSONArray,总之都会出现这种错误。
解决方案四:
你看看这个,会不会有帮助。
【云栖快讯】首届阿里巴巴中间件技术峰会,揭秘阿里10年分布式技术沉淀!阿里高可用体系核心缔造者、全链路压测创始人,DRDS与TDDL负责人等大咖出场,干货分享,不可错过!&&
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效率,降低 IT 成本...
RDS是一种稳定可靠、可弹性伸缩的在线数据库服务。支持MySQL、SQL Server、PostgreSQL、高...new JSONObject(String)为什么报错
用到的jar包如下:
commons-lang.jar
commons-beanutils.jar
commons-collections.jar
commons-logging.jar&
ezmorph.jar
json-lib-2.2.2-jdk15.jar
以下是问题补充:
:用到的jar包如下:
commons-lang.jar
commons-beanutils.jar
commons-collections.jar
commons-logging.jar
ezmorph.jar
json-lib-2.2.2-jdk15.jar
话说字符串类型的不用引号真的好吗?
--- 共有 2 条评论 ---
: 哦哦,原来是构造方法用错的原因,用JSONObject.from...那个方法吧
引用来自“杨延庆”的评论你的用户,日期格式这些值一个引号都没有,当然会有问题。
用了也不行啊。。。。。
你这是什么JSON包? 光发个代码怎么解决问题?
另外, new JSONObject(String)没有这个构造方法啊
你应该是传MAP进去才对
--- 共有 1 条评论 ---
引用来自“一堆BUG”的评论
你这是什么JSON包? 光发个代码怎么解决问题?
另外, new JSONObject(String)没有这个构造方法啊
你应该是传MAP进去才对
并没有map选项
你的用户,日期格式这些值一个引号都没有,当然会有问题。
从API来看, 你应该使用
JSONObject jsonObj = JSONObject.fromObject("...");
引用来自“杨延庆”的评论你的用户,日期格式这些值一个引号都没有,当然会有问题。引用来自“深蓝浅爱”的评论
用了也不行啊。。。。。
JSON的格式
属性或字段的名字——必须用引号
值——字符串必须用引号,数值、布尔类型和嵌套的JSONObject、JSONArray必须不用引号
你用的是json-lib-2.2.2也就是net.sf的.
这个json库不是这么用的.
JSONObject json = JSONObject.fromObject(jsonStr...);
赶紧采纳答案给分吧!
key,和字符串value加上双引号应该没问题吧
JSONObject json = new JSONObject("{\"name\":\"user\"}");
if (json.has("name")) {
System.out.println(json.get("name"));温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
快乐些,正直些,稳健些
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(6194)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'json-c-0.9库的json_object_object_get()引发崩溃问题',
blogAbstract:'&&&&& 在linux下编译开源的json-c-0.9库,在json对象不符合标准格式时,引发segmentation fault问题,程序退出。没有任何响应,这实在是让人无语。&&&& 经发现与json_tokener_parse() 失败有很大关系。1. 错误的情况这里先复习一下json提取子对象的一般过程,先parse,再get object, &&&& json_object *newobj=NULL;&&& newobj = json_tokener_parse(mystr);&&',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:3,
publishTime:0,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'快乐些,正直些,稳健些',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 显示网络连接图标 的文章

 

随机推荐