-1

내비게이션 서랍과 함께 facebook login tutorial을 구현하려고합니다. 서랍을 성공적으로 만들었지 만 에뮬레이터에서 해봤을 때 다른 레이아웃 (조각)의 일부 임에도 불구하고 서랍 로그인 버튼이 서랍 위에 나타납니다. 여기내비게이션 서랍에 Facebook 로그인 버튼이 나타납니다

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<!-- The main content view --> 
<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<!-- The navigation drawer --> 
<ListView android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:divider="#ff939393" 
    android:dividerHeight="1dp" 
    android:background="#ff333333"/> 

</android.support.v4.widget.DrawerLayout> 

그리고 내 조각 레이아웃입니다 : 여기 내 MainActivity 레이아웃의

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/facebook_login_view" 
android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
android:weightSum="1"> 

<com.facebook.widget.LoginButton android:id="@+id/authButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:gravity="center|center_horizontal" 
    android:layout_marginTop="40dp" /> 

<TextView 
    android:id="@+id/textView" 
    android:layout_width="312dp" 
    android:layout_height="101dp" 
    android:text="@string/please_login_with_facebook" 
    android:padding="10dp" 
    android:textStyle="bold" 
    android:typeface="serif" 
    android:singleLine="false" 
    android:layout_weight="0.13" 
    android:textAlignment="center" 
    android:gravity="center" 
    android:layout_gravity="center_horizontal" 
    android:layout_marginTop="150dp" /> 

<Button android:id="@+id/connection_settings_button" 
    android:layout_width="188dp" 
    android:layout_height="wrap_content" 
    android:text="@string/turn_on_internet_button" 
    android:layout_gravity="center" 
    android:layout_marginTop="36dp" 
    android:visibility="invisible" /> 
</FrameLayout> 

는 그리고 이것은 MainActivity 클래스입니다 : 필요한 경우

public class MainActivity extends ActionBarActivity { 

private String[] mDrawerTitles; 
private DrawerLayout mDrawerLayout; 
private ListView mDrawerList; 
private FacebookLoginFragment fbFragment; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main_activity_layout); 

    mDrawerTitles = getResources().getStringArray(R.array.nav_drawer_items); 
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    mDrawerList = (ListView) findViewById(R.id.left_drawer); 
    // Set the adapter for the list view 
    mDrawerList.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, mDrawerTitles)); 
    // Set the list's click listener 
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); 

    if (savedInstanceState == null) { 
     // Add the fragment on initial activity setup 
     fbFragment = new FacebookLoginFragment(); 
     getSupportFragmentManager() 
       .beginTransaction() 
       .add(android.R.id.content, fbFragment) 
       .commit(); 
    } else { 
     // Or set the fragment from restored state info 
     fbFragment = (FacebookLoginFragment) getSupportFragmentManager().findFragmentById(android.R.id.content); 
    } 
} 

private class DrawerItemClickListener implements ListView.OnItemClickListener { 
    @Override 
    public void onItemClick(AdapterView parent, View view, int position, long id) { 
     selectItem(position); 
    } 
} 


private void selectItem(int position) { 
    // Highlight the selected item, update the title, and close the drawer 
    mDrawerList.setItemChecked(position, true); 
    setTitle(mDrawerTitles[position]); 
    mDrawerLayout.closeDrawer(mDrawerList); 
} 


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

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    // Handle action bar item clicks here. The action bar will 
    // automatically handle clicks on the Home/Up button, so long 
    // as you specify a parent activity in AndroidManifest.xml. 
    int id = item.getItemId(); 
    if (id == R.id.action_settings) { 
     return true; 
    } 
    return super.onOptionsItemSelected(item); 
} 
} 

내가 더 많은 코드를 게시합니다. 불행히도 나는 여전히 이미지 게시에 대한 명성이 없지만 here is my problem. 어떤 도움이라도 대단히 감사합니다!

답변

1

FragmentTransaction.replaceFacebookLoginFragment 인 경우 android.R.id.content을 사용하지 마십시오. 대신 DrawerLayout의 콘텐츠 (이 경우 R.id.content_frame)의 역할을하는 FrameLayout의 ID를 사용하십시오.

+0

대단히 고맙습니다. 그게 내 문제를 해결했습니다! –

+0

@ PedroGuerra 답변을 수락 한 것으로 표시 하시겠습니까? – adneal

+0

오랫동안 복용 해 주셔서 죄송합니다. 나는 바빴습니다. 다시 한번 감사드립니다! –

관련 문제