2013-04-20 76 views
0

我正在使用圖片從url加載的源代碼。圖像鏈接存儲在一個json文件中,並將json文件存放在服務器中。但我希望json文件本地存儲可能是資產或可繪製的。 我的問題是,如果我使用資產管理器,它必須使用流管理器和流管理器不坐在與加載圖像URL的上下文相關的url。 如果我將config_wallpaper_manifest_url的網址更改爲loacal資產網址,即。 example.json,同樣不會加載。 這可能是什麼解決方案?謝謝。在Android中加載帶有圖片url的本地json文件

public void loadData (Bundle savedInstanceState) { 

    // Check Network State 
    if (!NetworkUtil.getNetworkState(this)) { 
     final RetryFragment fragment = RetryFragment.getFragmentWithMessage("No connection"); 
     this.addFragment(fragment, RetryFragment.TAG, true); 
     return; 
    } 



    if (savedInstanceState == null || savedInstanceState.get(KEY_LIST_DATA) == null) { 
     final String url = super.getResources().getString(R.string.config_wallpaper_manifest_url); 
     if (url != null && URLUtil.isValidUrl(url)) { 
      // Add Loading Fragment 
      final LoadingFragment fragment = new LoadingFragment(); 
      this.addFragment(fragment, LoadingFragment.TAG, true); 

      // Load Data 
      final RestClientHandler handler = new RestClientHandler(this); 
      RestClient.get(this, url, handler); 
     } 

    } else { 
     Log.i(TAG, "Restored Instance"); 
     this.mData = (ArrayList<NodeCategory>) savedInstanceState.get(KEY_LIST_DATA); 
     this.mPosition = savedInstanceState.getInt(KEY_LIST_POSITION); 
     if (this.mPosition != -1) { 
      mIgnoreSelection = true; 
     } 

     this.configureActionBar(); 
    } 
} 

回答

相關問題