2016-06-21 5 views
0

그래서 Activity와 해당 XML 파일이 있습니다. 둘 중 어느 것도 팹과 관련이 없습니다 (내가 팹을 지운 이후). 그러나 앱을 만들고 실행할 때 "유령 팹"이 계속 나타납니다. 클릭 할 수 없기 때문에 모퉁이에 자리 잡고 있으며이를 제거하는 방법을 모릅니다.FAB이없는 작업에 나타나는 FAB

활동 :

package example.com.musicapptest; 

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentPagerAdapter; 
import android.support.v4.view.ViewPager; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.LayoutInflater; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.widget.ProgressBar; 
import android.widget.TextView; 

public class HostMainPage extends AppCompatActivity { 

/** 
* The {@link android.support.v4.view.PagerAdapter} that will provide 
* fragments for each of the sections. We use a 
* {@link FragmentPagerAdapter} derivative, which will keep every 
* loaded fragment in memory. If this becomes too memory intensive, it 
* may be best to switch to a 
* {@link android.support.v4.app.FragmentStatePagerAdapter}. 
*/ 
private SectionsPagerAdapter mSectionsPagerAdapter; 

/** 
* The {@link ViewPager} that will host the section contents. 
*/ 
private ViewPager mViewPager; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_host_main_page); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    // Create the adapter that will return a fragment for each of the three 
    // primary sections of the activity. 
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); 

    // Set up the ViewPager with the sections adapter. 
    mViewPager = (ViewPager) findViewById(R.id.container); 
    mViewPager.setAdapter(mSectionsPagerAdapter); 
} 


@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    // Inflate the menu; this adds items to the action bar if it is present. 
    getMenuInflater().inflate(R.menu.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(); 

    //noinspection SimplifiableIfStatement 
    if (id == R.id.action_settings) { 
     return true; 
    } 

    return super.onOptionsItemSelected(item); 
} 

/** 
* A placeholder fragment containing a simple view. 
*/ 
public static class PlaceholderFragment extends Fragment { 
    /** 
    * The fragment argument representing the section number for this 
    * fragment. 
    */ 
    private static final String ARG_SECTION_NUMBER = "section_number"; 

    public PlaceholderFragment() { 
    } 

    /** 
    * Returns a new instance of this fragment for the given section 
    * number. 
    */ 
    public static PlaceholderFragment newInstance(int sectionNumber) { 
     PlaceholderFragment fragment = new PlaceholderFragment(); 
     Bundle args = new Bundle(); 
     args.putInt(ARG_SECTION_NUMBER, sectionNumber); 
     fragment.setArguments(args); 
     return fragment; 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     //Linking up values in fragment_main.xml to the MainActivity 
     View rootView = inflater.inflate(R.layout.fragment_host_main_page, container, false); 
     TextView splashTitleView = (TextView) rootView.findViewById(R.id.host_splash_title); 
     TextView splashBodyView = (TextView) rootView.findViewById(R.id.host_splash_body); 
     ProgressBar splashProgress = (ProgressBar) rootView.findViewById(R.id.host_splash_progres); 
     Button hostButton = (Button) rootView.findViewById(R.id.host_start_button); 
     hostButton.setVisibility(View.GONE); 

     /* 
      Setting up which splash page will be displayed as the user progresses throughout the welcome splash page 
     */ 
     if (getArguments().getInt(ARG_SECTION_NUMBER) == 1) { 
      splashTitleView.setText("Host Welcome"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(20); 
     } else if (getArguments().getInt(ARG_SECTION_NUMBER) == 2) { 
      splashTitleView.setText("Create a Party ID"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(40); 
     } else if (getArguments().getInt(ARG_SECTION_NUMBER) == 3) { 
      splashTitleView.setText("People Joint"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(60); 
     } else if (getArguments().getInt(ARG_SECTION_NUMBER) == 4) { 
      splashTitleView.setText("Vote, Suggest, or View Leaderboards"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(80); 
     } 
     else if (getArguments().getInt(ARG_SECTION_NUMBER) == 5) { 
      hostButton.setVisibility(View.VISIBLE); 
      splashTitleView.setText("Start Hosting"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(100); 
     } 
     //Default frag if for some reason there is an IndexOutOfBoundsException() 
     else { 
      splashTitleView.setText("Get Started Fragment"); 
      splashBodyView.setText("Filler Text"); 
      splashProgress.setProgress(100); 
     } 

     return rootView; 
    } 
} 

/** 
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to 
* one of the sections/tabs/pages. 
*/ 
public class SectionsPagerAdapter extends FragmentPagerAdapter { 

    public SectionsPagerAdapter(FragmentManager fm) { 
     super(fm); 
    } 

    @Override 
    public Fragment getItem(int position) { 
     // getItem is called to instantiate the fragment for the given page. 
     // Return a PlaceholderFragment (defined as a static inner class below). 
     return PlaceholderFragment.newInstance(position + 1); 
    } 

    @Override 
    public int getCount() { 
     // Show 5 total pages. 
     return 5; 
    } 

    @Override 
    public CharSequence getPageTitle(int position) { 
     switch (position) { 
      case 0: 
       return "SECTION 1"; 
      case 1: 
       return "SECTION 2"; 
      case 2: 
       return "SECTION 3"; 
      case 3: 
       return "SECTION 4"; 
      case 4: 
       return "SECTION 5"; 
     } 
     return null; 
    } 
} 

}

그리고 XML : 여기

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="example.com.musicapptest.HostMainPage$PlaceholderFragment"> 

<TextView 
    android:id="@+id/host_splash_title" 
    android:layout_width="300dp" 
    android:layout_height="100dp" 
    android:gravity="center" 
    android:layout_marginTop="22dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true"/> 

<TextView 
    android:layout_width="500dp" 
    android:layout_height="100dp" 
    android:gravity="center" 
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:id="@+id/host_splash_body" 
    android:layout_below="@id/host_splash_title" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentEnd="true" 
    android:layout_marginTop="20dp" /> 

<ProgressBar 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="300dp" 
    android:layout_height="wrap_content" 
    android:id="@+id/host_splash_progres" 
    android:layout_marginTop="48dp" 
    android:layout_below="@+id/host_splash_body" 
    android:layout_alignStart="@+id/host_splash_title" /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/host_start_button" 
    android:id="@+id/host_start_button" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="68dp" /> 

</RelativeLayout> 

이의 이미지입니다 내가는 참조 용으로보고 있어요 :

Ghost FAB

고마워!

+0

이 XML은 아마도 'Fragment' ... 및'Activity'에 대한 것입니까? – snachmsm

답변

0

잘못된 레이아웃 XML 파일을보고 있습니다. 레이아웃의 도구 모음을 찾으려고합니다.

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 

아직 붙여 넣은 레이아웃에는 도구 모음이 없습니다. FAB를 포함하는 activity_host_main_page.xml이라는 또 다른 레이아웃 파일이 있어야합니다.

관련 문제