조각 문제로 하나의 창 에서 열린 목록보기에 어떤 항목 중 하나 개를 클릭 내가 내 교체하려는 경우 내가 목록보기 이 간단한 프로젝트를 이 프로젝트 http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/필요한 android.support.v4.app.fragment
내가 스위치 케이스 내 mainactivty 클래스를 넣어하지만 나에게 내가 수입 android.support.v4.app.Fragment를 가져올 첫 번째 사진 이 오류 을 얻을에이 탭 조각에와 조각 뿐만 아니라 동일한 promplem
,363,210이는 또 다른 액티비티 클래스는 사진에 오류가있는 다른 클래스 클래스 fragmentA
public class fragmentA extends Fragment implements AdapterView.OnItemClickListener
{
ListView list;
comunicatir com;
@Override
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment1,container,false);
list=(ListView)view.findViewById(R.id.listView1);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(),
R.array.chapters, android.R.layout.simple_list_item_1);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
return view;
}
public void setcomunicatir (comunicatir comunicator)
{
this.com=comunicator;
}
@Override
public void onItemClick(AdapterView<?> adapterView, View veiw, int i, long l) {
com.respned(i);
}
public interface comunicatir
{
public void respned(int index);
}
}
public class fragmentB extends Fragment
{
TextView text;
TextView textView2;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment2, container, false);
//text = (TextView) view.findViewById(R.id.textView1);
//imgv=(ImageView) view.findViewById(R.id.imageView1);
textView2 =(TextView)view.findViewById(R.id.textView22);
return view;
}
public void cahngedata(int index)
{
/*String[] descrption =getResources().getStringArray(R.array.hadeith);
text.setText(descrption[index]);*/
String []Hadith=getResources().getStringArray(R.array.hadeith);
//imgv.setImageResource(img[index]);
textView2.setText(Hadith[index]);
//int []descrption =getResources().getIntArray(img[index]);
// imgv.setImageResource(descrption[index]);
/*text.setText(descrption[index]);
int arr[]=getResources().getIntArray(img[index]);
imgv.setImageResource(arr[index]);*/
}
}
public class AnotherActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.another);
Intent intent = getIntent();
int index= intent.getIntExtra("index", 0);
fragmentB f2= (fragmentB)
getFragmentManager().
findFragmentById(R.id.fragment2);
if (f2!=null)
f2.cahngedata(index);
}
}
내 프로젝트 .... Main2Activity 클래스
public class Main2Activity extends AppCompatActivity implements fragmentA.comunicatir
{
fragmentA f1;
fragmentB f2;
FragmentManager manegaer;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
manegaer=getSupportFragmentManager();
f1=(fragmentA)manegaer.findFragmentById(R.id.fragment1);
f1.setcomunicatir(this);
}
@Override
public void respned(int index){
f2=(fragmentB)manegaer.findFragmentById(R.id.fragment2);
if(f2!=null&&f2.isVisible()){
f2.cahngedata(index);
}else{
Intent intent=
new Intent(this,
AnotherActivity.class);
intent.putExtra("index",index);
startActivity(intent);
}
}
}
의 clases입니다 2
getItem()은 삽입 방법이므로 삭제할 수 없습니다 –
"return new Tab1()"을 입력하십시오. 그것은 중요하지 않습니다 당신이 그것을 사용하지 않을 경우 –
괜찮아요하지만 내 Main2Activity를 표시하지 Main2Activity을 조각하려고하면 조각을 확장하려고이 사진을 참조하십시오 https://drive.google.com/file/d/0ByZGzcCum73xQ0trVEh3cmhiNHM/view?usp=sharing –