2013-12-15 29 views
0


有沒有一個選項可以修改 android全景客戶端上的內容視圖?
Android Panorama Client - 如何修改視圖?

例如,我想在頂部顯示操作欄。但是目前操作欄僅顯示在開始處,隨後由加載的全景客戶端隱藏,因爲全景客戶端始終以全屏模式顯示,儘管它是在額外的片段中啓動的。


我現在試圖把全景客戶端通過一個片段的分離式框架 - 這是到目前爲止我的代碼:


1.這是活動白衣全景片段和文本字段:

public class PanoramaActivity extends Activity { 

public static final String TAG = PanoramaActivity.class.getSimpleName(); 

private ActionBar actionBar; 
private Fragment panoramaClient = new PanoramaClientFragment(); 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_snow); 
    actionBar = getActionBar(); 
    actionBar.setDisplayHomeAsUpEnabled(true); 


    FragmentManager fragMan = getFragmentManager(); 
    FragmentTransaction fragTrans = fragMan.beginTransaction(); 

    fragTrans.replace(R.id.panoramaCLientFrame, panoramaClient, "PANO"); 
    fragTrans.commit(); 

    //Non fullscreen 
    requestWindowFeature(Window.FEATURE_ACTION_BAR); 
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.panorama, menu); 
    return true; 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    switch (item.getItemId()) { 
    case android.R.id.home: 
     onBackPressed(); 
     break; 

    default: 
     return super.onOptionsItemSelected(item); 
    } 
    return true; 
} 
} 


2.And這是片段類全景客戶端:

public class PanoramaClientFragment extends Fragment implements ConnectionCallbacks, 
OnConnectionFailedListener, OnPanoramaInfoLoadedListener { 

private View view; 
private PanoramaClient panoramaClient; 

public static final String TAG = PanoramaClientFragment.class.getSimpleName(); 

public PanoramaClientFragment() { 
    // TODO Auto-generated constructor stub 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle  savedInstanteState){ 
    view = inflater.inflate(R.layout.panorama_client, container, false); 
    return view; 
} 

@Override 
public void onCreate(Bundle savedInstanceState){ 
    super.onCreate(savedInstanceState); 
    panoramaClient = new PanoramaClient(getActivity().getApplicationContext(), this, this); 

//Non fullscreen 
//getActivity().requestWindowFeature(Window.FEATURE_ACTION_BAR); 
//getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 
//getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 

@Override 
public void onStart() { 
    super.onStart(); 
    panoramaClient.connect(); 
} 

@Override 
public void onPanoramaInfoLoaded(ConnectionResult result, Intent viewerIntent) { 
    if (result.isSuccess()) { 
     Log.i(TAG, "found viewerIntent: " + viewerIntent); 
     if (viewerIntent != null) { 
      startActivity(viewerIntent); 
     } 
    } else { 
     Log.e(TAG, "error: " + result); 
    } 
} 

@Override 
public void onConnectionFailed(ConnectionResult status) { 
    Log.e(TAG, "connection failed: " + status); 
} 

@Override 
public void onConnected(Bundle arg0) { 
    Uri uri = Uri.parse("android.resource://" + this.getActivity().getPackageName() + "/" + R.raw.pano1); 
    panoramaClient.loadPanoramaInfo(this, uri); 
} 

@Override 
public void onDisconnected() { 
    // Do nothing. 
} 

@Override 
public void onStop() { 
    super.onStop(); 
    panoramaClient.disconnect(); 
} 
} 

如果我取消的片段類三個「非全屏」 -lines,應用程序崩潰,並說:

android.util.AndroidRuntimeException:requestFeature()必須在添加之前調用content


感謝您的回覆。 問候。

回答

0

嘗試創建一個片段並向其添加全景客戶端活動。

+0

謝謝。但它不能那樣工作。 –

0

我覺得你不能顯示操作欄的一個簡單的原因,當你的全景信息被加載時,你正在開始一個完全不受你控制的新活動。

if (viewerIntent != null) { 
    startActivity(viewerIntent); 
} 

因此,您的代碼嘗試修改處理PanoramaClient實例的活動,但不是加載全景圖像的活動。