我正在實現一個應用程序,該應用程序在一個活動中具有圖像的網格視圖,並且在全屏中包含圖像的每個圖像都具有一個片段。當我點擊網格中的任何圖像時,它應該打開相應的片段。但是,我們不能使用意圖來做到這一點。 這裏是我的代碼Android使用意圖從活動中打開片段
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
// TODO Auto-generated method stub
if(position==0)
{
Intent i=new Intent(Gallery.this,ImageFrag1.class);
startActivity(i);
}
和片段
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ImageFrag1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.imagefrag1, container, false);
}
}
這個片段綁定到一個活動ImagesSwipe。那麼我該如何實現網格視圖項目及其相應片段之間的轉換。 謝謝
爲什麼每個圖像的片段? – techiServices
我正在使用滑動選項卡導航,所以我已經將每個選項卡保存爲圖像 –
我可以想出很多解決方案,具體取決於應用程序應該如何根據屏幕大小等進行操作.GridView在'Fragment'中加載? – techiServices