2016-11-09 18 views
0

を表示していないが、私は私のプロジェクトを実行すると、それがクラッシュし、いずれかがこれで私を助けてerror..can以下与える?次は、任意のヘルプがにappriciatedされるだろう、私のスニペットコードであるCoverFlowのは、私は私の画像を表示する<a href="https://github.com/moondroid/CoverFlow" rel="nofollow noreferrer">coverflow</a>を使用していた画像

: FATAL EXCEPTION: main Process: com.example.daysheft.dpc, PID: 21087 java.lang.NullPointerException: Attempt to invoke interface method 'int android.widget.Adapter.getCount()' on a null object reference at it.moondroid.coverflow.components.ui.containers.FeatureCoverFlow.dispatchDraw(FeatureCoverFlow.java:471) at android.view.View.updateDisplayListIfDirty(View.java:15185) at android.view.View.draw(View.java:15964)

CoverflowActivity.java

public class CoverFlowActivity extends ActionBarActivity { 

    private FeatureCoverFlow mCoverFlow; 
    private CoverFlowAdapter mAdapter; 
    // private ArrayList<GameEntity> mData = new ArrayList<>(0); 
    private TextSwitcher mTitle; 
    private String productlanding_url; 
    private String ProductID; 

    private ProgressDialog pDialog; 
    private ArrayList<PackListModel> categorylist; 
    private ArrayList<PackSizeModel> subcat_list; 
    private PackListModel cm; 



    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_coverflow); 

     ProductID=getIntent().getStringExtra("Product_Id"); 

     productlanding_url=Globaldata.APP_URL+"ProductLanding"; 
     pDialog = new ProgressDialog(this); 
     // Showing progress dialog before making http request 
     pDialog.setMessage("Loading..."); 
     pDialog.show(); 

     GetProductLanding(); 

     /* mData.add(new GameEntity(R.drawable.tesss, R.string.title1)); 
     mData.add(new GameEntity(R.drawable.tesss, R.string.title2)); 
     mData.add(new GameEntity(R.drawable.tesss, R.string.title3)); 
     mData.add(new GameEntity(R.drawable.tesss, R.string.title4));*/ 

     /* mTitle = (TextSwitcher) findViewById(R.id.title); 
     mTitle.setFactory(new ViewSwitcher.ViewFactory() { 
      @Override 
      public View makeView() { 
       LayoutInflater inflater = LayoutInflater.from(CoverFlowActivity.this); 
       TextView textView = (TextView) inflater.inflate(R.layout.item_title, null); 
       return textView; 
      } 
     }); 
     Animation in = AnimationUtils.loadAnimation(this, R.anim.slide_in_top); 
     Animation out = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom); 
     mTitle.setInAnimation(in); 
     mTitle.setOutAnimation(out); 
*/ 
     /*mAdapter = new CoverFlowAdapter(CoverFlowActivity.this,categorylist); 
     mAdapter.setData(categorylist);*/ 
     mCoverFlow = (FeatureCoverFlow) findViewById(R.id.coverflow); 
    // mCoverFlow.setAdapter(mAdapter); 

     mCoverFlow.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
       /* Toast.makeText(CoverFlowActivity.this, 
         getResources().getString(mData.get(position).titleResId), 
         Toast.LENGTH_SHORT).show();*/ 
      } 
     }); 

     mCoverFlow.setOnScrollPositionListener(new FeatureCoverFlow.OnScrollPositionListener() { 
      @Override 
      public void onScrolledToPosition(int position) { 
       // mTitle.setText(getResources().getString(mData.get(position).titleResId)); 
      } 

      @Override 
      public void onScrolling() { 
       //mTitle.setText(""); 
      } 
     }); 

    } 

    public void GetProductLanding() 
    { 

     showpDialog(); 

     Map<String, String> params = new HashMap<String, String>(); 
     params.put("productId", "1004"); 
     params.put("userID", "1"); 

     System.out.println("PARAMS ProductLanding" + params); 
     JsonArrayRequest request = new JsonArrayRequest(Request.Method.POST, productlanding_url, new JSONObject(params), 
       new Response.Listener<JSONArray>() { 
        @Override 
        public void onResponse(JSONArray response) { 
         System.out.println("response of ProductLanding" + response.toString()); 

         try { 

          for (int i = 0; i < response.length(); i++) { 

           JSONObject person = (JSONObject) response 
             .get(i); 
           JSONArray itemlist=person.optJSONArray("itemList"); 
           System.out.println("ProductLanding itemlist"+itemlist); 

           for(int j=0;j<itemlist.length();j++) 
           { 
            JSONObject itmobj = (JSONObject)itemlist 
              .get(j); 


            JSONArray typemasters=itmobj.optJSONArray("packInfo"); 

            categorylist=new ArrayList<PackListModel>(); 

            for(int k=0;k<typemasters.length();k++) 
            { 

             subcat_list = new ArrayList<PackSizeModel>(); 
             JSONObject typemasterobj=(JSONObject)typemasters.get(k); 
             cm=new PackListModel(); 
             cm.setProductLanding_packId(typemasterobj.getString("packId")); 
             cm.setProductLanding_packLink(typemasterobj.getString("packDesc")); 
             cm.setProductLanding_packDesc(typemasterobj.getString("packLink")); 


             if (typemasterobj.getString("packSizeDetails").equals("null")) { 
              System.out.println("arr null"); 
             } else { 
              JSONArray SubcategoryArr = typemasterobj.optJSONArray("packSizeDetails"); 

              for (int l = 0; l < SubcategoryArr.length(); l++) { 

               JSONObject Subcategoryobj = SubcategoryArr.getJSONObject(l); 
               String packQty = Subcategoryobj.getString("packQty"); 
               String packSize = Subcategoryobj.getString("packSize"); 
               String sellingPrice = Subcategoryobj.getString("sellingPrice"); 
               String lineThroughPrice = Subcategoryobj.getString("lineThroughPrice"); 
               String packSizePrice = Subcategoryobj.getString("packSizePrice"); 
               String freeShipping = Subcategoryobj.getString("freeShipping"); 
               String reOrderPrice = Subcategoryobj.getString("reOrderPrice"); 
               PackSizeModel ch = new PackSizeModel(); 
               ch.setPackSize_packQty(packQty); 
               ch.setPackSize_packSize(packSize); 
               ch.setPackSize_sellingPrice(sellingPrice); 
               ch.setPackSize_lineThroughPrice(lineThroughPrice); 
               ch.setPackSize_packSizePrice(packSizePrice); 
               ch.setPackSize_freeShipping(freeShipping); 
               ch.setPackSize_reOrderPrice(reOrderPrice); 
               // ch.setChild_Id(jo.getString("categoryID")); 
               subcat_list.add(ch); 
              } // for loop end 

              cm.setItems(subcat_list); 


             } 

             categorylist.add(cm); 

            } 

            System.out.println("SIZE"+categorylist.size()); 
            /* mAdapter = new CoverFlowAdapter(CoverFlowActivity.this,categorylist); 
            mAdapter.setData(categorylist); 
            mCoverFlow.setAdapter(mAdapter);*/ 
           } 

          } 


         } catch (JSONException e) { 
          e.printStackTrace(); 
          System.out.println("Error" + e.getMessage()); 
          // Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show(); 
         } 

         hidepDialog(); 
        } 
       }, 
       new Response.ErrorListener() { 
        @Override 
        public void onErrorResponse(VolleyError error) { 
         System.out.println("change Pass response -->> " + error.toString()); 
         hidepDialog(); 
        } 
       }); 

     request.setRetryPolicy(new 

       DefaultRetryPolicy(60000, 
       DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 
       DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); 


     Volley.newRequestQueue(CoverFlowActivity.this).add(request); 
    } 


    private void showpDialog() { 
     if (!pDialog.isShowing()) 
      pDialog.show(); 
    } 

    private void hidepDialog() { 
     if (pDialog.isShowing()) 
      pDialog.dismiss(); 
    } 


} 

答えて

0

あなたcategorylistあなたはmAdapterにそれを設定する前に値を持っている必要があります。 このエラーを解決するには、あなたのボレーリクエストに応じてmAdapterを初期化します。 あなたのアプリケーションに適している場合は、より良いソリューションのためにthisライブラリを使用してください。

+0

私のカテゴライズリストには値があります。 – albert

+0

この行のコメントを外します/ * mAdapter = new CoverFlowAdapter(CoverFlowActivity.this、categorylist); mAdapter.setData(categorylist); mCoverFlow.setAdapter(mAdapter); * /デバッグ値は、クラッシュするタイミングを表示します。また、私は適切な別の図書館を掲示しました。これはintial値をある整数値として設定し、カバーフローを正方形に設定したときに問題になります –

+0

私はリンクからモジュールとしてライブラリを追加しようとしました。エラー:(30、0)余分に 'supportV4'プロパティを取得できませんプロパティの拡張が存在しないので、 – albert

関連する問題

 関連する問題