无法启动活动错误:onCreate中的NullPointerException

时间:2015-03-14 08:26:43

标签: java android nullpointerexception syntax-error

当我点击产品ListView看产品datail有错误!的的NullPointerException

FragmentAllShop.java onClick listview项目将转到详细信息页面

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {  
    int detailshop_id = model.getShop_id();
    String shopID = String.valueOf(detailshop_id);
    Toast.makeText(FragmentAllShopping.this.getActivity(), "Select shopping_id: "+detailshop_id, Toast.LENGTH_SHORT).show();

    Intent shopDetail = new Intent(getActivity(), ShoppingDetailActivity.class);
    shopDetail.putExtra("shopID", shopID);
    startActivity(shopDetail);
}

ShoppingDetail.java 第89行代码出错 - &gt; TitleShop.setText(model.getShop_title());

    ShowImgProduct = (ImageView)findViewById(R.id.ShowImgProduct);
    TitleShop = (TextView)findViewById(R.id.TitleShop);
    TVPriceDetail = (TextView)findViewById(R.id.TVPriceDetail);
    DetailProduct = (TextView)findViewById(R.id.DetailProduct);
    TVuserPost = (TextView)findViewById(R.id.TVuserPost);

    show_shopdetail_id = getIntent().getStringExtra("shopID");
    detailshop_id = Integer.parseInt(show_shopdetail_id);

    JSONParser jspaser = new JSONParser();
    String url = "http://www.leveltistweb09.com/Hello_Oppa/get_shoppingdetail.php?shop_id="+detailshop_id;
    String dataJSON = jspaser.makeHttpRequest(url,JSONParser.methodGet, null);


    try {

        jsOBJ = new JSONObject(dataJSON);               
        int shop_id = jsOBJ.getInt("shop_id");
        String shop_img_url = jsOBJ.getString("shop_img_url");
        String shop_title = jsOBJ.getString("shop_title");
        String shop_price = "ราคา "+jsOBJ.getString("shop_price")+" บาท";
        String shop_detail = jsOBJ.getString("shop_detail");
        String user_display_name = "post by : "+jsOBJ.getString("user_display_name");
        String shop_email = jsOBJ.getString("shop_email");
        String shop_tel = jsOBJ.getString("shop_tel");


        model = new AllShop_Model(shop_id, shop_img_url, shop_title, shop_price, shop_detail, 
                user_display_name, shop_email, shop_tel);

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }


    TitleShop.setText(model.getShop_title());
    TVPriceDetail.setText(model.getShop_price());
    DetailProduct.setText(model.getShop_detail());
    TVuserPost.setText(model.getUser_display_name());

    String path = "http://su13540254.2th.asia/Hello_Oppa/img/";
    ShowImgProduct.setImageBitmap(loadBitmap(path+model.getShop_img_url()));
}   

error image click!! error on code at line 89 -> TitleShop.setText(model.getShop_title());

1 个答案:

答案 0 :(得分:0)

- 首先,您必须检查是否正确地获取 Json响应 ,然后检查响应是否正确然后您正确存储对象是否: - shop_title 此处不是空检查。

- 让我知道问题是否存在更多 感谢