항목 목록이있는 프래그먼트를 호스팅하는 활동을 시작합니다 ..조각을 시작하지 않는 문제를 해결하는 방법은 무엇입니까?
항목을 클릭하면. 레이아웃은 threePane에 대해 테스트됩니다.
public void onFeedSelected(Feed feed) {
if (isThreePane) {
addItemsFragment(feed);
}
else {
Intent i=new Intent(this, ItemsActivity.class);
i.putExtra(ItemsActivity.EXTRA_FEED_KEY, feed.getKey());
startActivity(i);
}
}
3 개의 창이 아니라면 볼 수 있듯이 활동이 시작됩니다. 일반 전화에서는 정상적으로 작동합니다.
그러나 태블릿 화면 인 경우 활동이 조각에서 실행되지 않습니다.
다음은 내 AddFeed() 메소드입니다.
public void addItemsFragment(Feed feed) {
FragmentManager fragMgr=getSupportFragmentManager();
ItemsFragment items=(ItemsFragment)fragMgr.findFragmentById(R.id.second_pane);
FragmentTransaction xaction=fragMgr.beginTransaction();
if (items==null) {
items=new ItemsFragment(true);
items.setOnItemListener(this);
xaction
.add(R.id.second_pane, items)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack(null)
.commit();
}
else {
ContentFragment content=
(ContentFragment)fragMgr.findFragmentById(R.id.third_pane);
if (content!=null) {
xaction.remove(content).commit();
fragMgr.popBackStack();
}
}
왜 출시되지 않았는지 이해하지 않습니다. 항목을 클릭하면 태블릿 장치에서 아무 작업도 수행하지 않습니다.
편집 :
private boolean isThreePane=false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FeedsFragment feeds
=(FeedsFragment)getSupportFragmentManager()
.findFragmentById(R.id.feeds);
feeds.setOnFeedListener(this);
isThreePane=(null!=findViewById(R.id.second_pane));
if (isThreePane) {
feeds.enablePersistentSelection();
}
}
isThreePane 변수 란 무엇입니까? 그리고 그것은 진실 또는 거짓으로 설정된 것입니까? 이 변수가 변경된 코드를 모두 게시 할 수 있습니까? 내 추측에 따르면 isThreePane은 타블렛상에서 어떤 이유로 든 true로 설정됩니다. if 및 else에 로그 메시지를 넣고 실제로 어떤 메시지가 있는지 확인할 수 있습니다. – FoamyGuy
내 편집을 확인하십시오. 방금 코드를 게시했습니다 –
어떤 타블렛을 사용하고 있습니까? 벌집인가 아닌가? – FoamyGuy