2016-10-28 3 views
0

このエラーは私のmasterブランチにのみ現れ、私はそれを他のブランチと比較しましたが、違いを見つけることはできません。私がエラーをクリックすると、私はsectionspagerアダプタを宣言する場所に私を指し示します。 psのイムは、まだ本当に新しいがイムこの全部間違っていけないをやってくれSectionPagerAdapterは機能しませんし、再起動が役に立たなかった

エラーを修正するために悪い感じので、もしこれが私の初めてのアプリですAndroidに

私の主な活動は、この

package com.madchallenge2016edwindaniel.upbirdwatchers; 


import android.content.pm.PackageManager; 
import android.graphics.Bitmap; 
import android.provider.MediaStore; 


import android.content.Intent; 
import android.content.SharedPreferences; 
import android.net.Uri; 
import android.support.annotation.NonNull; 
import android.support.design.widget.NavigationView; 

import android.support.design.widget.TabLayout; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v4.app.FragmentStatePagerAdapter; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentTransaction; 

import android.support.v4.view.GravityCompat; 
import android.support.v4.view.PagerAdapter; 
import android.support.v4.widget.DrawerLayout; 
import android.support.v7.app.ActionBarDrawerToggle; 
import android.support.v7.app.AlertDialog; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 

import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentPagerAdapter; 
import android.support.v4.view.ViewPager; 
import android.os.Bundle; 
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.ImageView; 
import android.widget.TextView; 




import android.widget.CompoundButton; 
import android.widget.Switch; 
import android.widget.TextView; 

import com.google.android.gms.appindexing.Action; 
import com.google.android.gms.appindexing.AppIndex; 
import com.google.android.gms.auth.api.Auth; 
import com.google.android.gms.auth.api.signin.GoogleSignInAccount; 
import com.google.android.gms.common.ConnectionResult; 
import com.google.android.gms.common.api.GoogleApiClient; 
import com.google.android.gms.common.api.ResultCallback; 
import com.google.android.gms.common.api.Status; 
import com.google.android.gms.auth.api.signin.GoogleSignInOptions; 
import com.google.android.gms.auth.api.signin.GoogleSignInResult; 


public class MainActivity extends AppCompatActivity implements 
    GoogleApiClient.ConnectionCallbacks, 
    GoogleApiClient.OnConnectionFailedListener { 


//Defining Variables 
public static final int REQUEST_CAPTURE = 1; 
ImageView reslut_photots; 
private Toolbar toolbar; 
private NavigationView navigationView; 
private DrawerLayout drawerLayout; 
private Button btnLogout; 
private SharedPreferences preferenceSettings; 
private SharedPreferences.Editor preferenceEditor; 
private static final int PREFERENCE_MODE_PRIVATE = 0; 


/** 
* The {@link 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 FragmentStatePagerAdapter}. 
*/ 
private SectionsPagerAdapter mSectionsPagerAdapter; 

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


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


    Button click = (Button) findViewById(R.id.BtnCamera); 
    reslut_photots = (ImageView) findViewById(R.id.BtnCamera); 

    if (!hasCamera()) { 
     //click.setEnabled(false); 
    } 


    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) 
      .requestEmail() 
      .build(); 
    mGoogleApiClient = new GoogleApiClient.Builder(this) 
      .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) 
      .addApi(Auth.GOOGLE_SIGN_IN_API, gso) 
      .addApi(AppIndex.API).build(); 


    //Background 
    getWindow().setBackgroundDrawableResource(R.drawable.nature_background); 

    /** //Logout button listener en logout 
    btnLogout = (Button) findViewById(R.id.Logout); 
    btnLogout.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v){ 
      Auth.GOOGLE_SIGN_IN_API.signOut(mGoogleApiClient).setResultCallback(
        new ResultCallback<Status>(){ 
         @Override public void onResult(Status status){ 
         } 
        }); 


     } 
    }); 
    */ 

    // Initializing Toolbar and setting it as the actionbar 
    toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    //Initializing NavigationView 
    navigationView = (NavigationView) findViewById(R.id.navigation_view); 

    //Setting Navigation View Item Selected Listener to handle the item click of the navigation menu 
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { 
     // This method will trigger on item Click of navigation menu 
     @Override 
     public boolean onNavigationItemSelected(MenuItem menuItem) { 
      //Checking if the item is in checked state or not, if not make it in checked state 
      if (menuItem.isChecked()) menuItem.setChecked(false); 
      else menuItem.setChecked(true); 

      //Closing drawer on item click 
      drawerLayout.closeDrawers(); 

      //Check to see which item was being clicked and perform appropriate action 
      switch (menuItem.getItemId()) { 
       case R.id.item1: 
        Intent intent = new Intent(getApplicationContext(), MapActivity.class); 
        startActivity(intent); 
        return true; 
       case R.id.item2: 

        return true; 
       default: 

        return true; 
      } 
     } 

    }); 




    // Initializing Drawer Layout and ActionBarToggle 
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.openDrawer, R.string.closeDrawer){ 

     @Override 
     public void onDrawerClosed(View drawerView) { 
      // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank 
      super.onDrawerClosed(drawerView); 
     } 

     @Override 
     public void onDrawerOpened(View drawerView) { 
      // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank 

      super.onDrawerOpened(drawerView); 
     } 
    }; 

    //Setting the actionbarToggle to drawer layout 
    drawerLayout.setDrawerListener(actionBarDrawerToggle); 

    //calling sync state is necessay or else your hamburger icon wont show up 
    actionBarDrawerToggle.syncState(); 


    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); 

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); 
    tabLayout.setupWithViewPager(mViewPager); 
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); 



} 

public boolean hasCamera() { 
    return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); 
} 


public void luanchCamera (View v) { 
    Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    startActivityForResult(i, REQUEST_CAPTURE); 
} 

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == REQUEST_CAPTURE && resultCode == RESULT_OK) { 
     Bundle extras = data.getExtras(); 
     Bitmap photo = (Bitmap) extras.get("data"); 
     reslut_photots.setImageBitmap(photo); 
    } 

} 
@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. 
    switch (item.getItemId()) { 
     case android.R.id.home: 
      drawerLayout.openDrawer(GravityCompat.START); 
      return true; 
    } 




    return super.onOptionsItemSelected(item); 

} 



@Override 
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { 

} 

@Override 
public void onConnected(Bundle bundle) { 

} 

@Override 
public void onConnectionSuspended(int i) { 

} 

@Override 
public void onStart() { 
    super.onStart(); 

    // ATTENTION: This was auto-generated to implement the App Indexing API. 
    // See https://g.co/AppIndexing/AndroidStudio for more information. 
    mGoogleApiClient.connect(); 
    Action viewAction = Action.newAction(
      Action.TYPE_VIEW, // TODO: choose an action type. 
      "Main Page", // TODO: Define a title for the content shown. 
      // TODO: If you have web page content that matches this app activity's content, 
      // make sure this auto-generated web page URL is correct. 
      // Otherwise, set the URL to null. 
      Uri.parse("http://host/path"), 
      // TODO: Make sure this auto-generated app deep link URI is correct. 
      Uri.parse("android-app://com.madchallenge2016edwindaniel.upbirdwatchers/http/host/path") 
    ); 
    AppIndex.AppIndexApi.start(mGoogleApiClient, viewAction); 
} 

@Override 
public void onStop() { 
    super.onStop(); 

    // ATTENTION: This was auto-generated to implement the App Indexing API. 
    // See https://g.co/AppIndexing/AndroidStudio for more information. 
    Action viewAction = Action.newAction(
      Action.TYPE_VIEW, // TODO: choose an action type. 
      "Main Page", // TODO: Define a title for the content shown. 
      // TODO: If you have web page content that matches this app activity's content, 
      // make sure this auto-generated web page URL is correct. 
      // Otherwise, set the URL to null. 
      Uri.parse("http://host/path"), 
      // TODO: Make sure this auto-generated app deep link URI is correct. 
      Uri.parse("android-app://com.madchallenge2016edwindaniel.upbirdwatchers/http/host/path") 
    ); 
    AppIndex.AppIndexApi.end(mGoogleApiClient, viewAction); 
    mGoogleApiClient.disconnect(); 

} 
    @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) { 
      if (getArguments().getInt(ARG_SECTION_NUMBER)==1){ 
      View rootView = inflater.inflate(R.layout.fragment_sub_birds_you_seen, container, false); 
      return rootView; 
      } else if (getArguments().getInt(ARG_SECTION_NUMBER)==2) { 
      View rootView = inflater.inflate(R.layout.fragment_sub_seed_eating, container, false); 
      return rootView; 

      } else if (getArguments().getInt(ARG_SECTION_NUMBER)==3) { 
      View rootView = inflater.inflate(R.layout.fragment_sub_insect_eeters, container, false); 
      return rootView; 


      }else { 

      View rootView = inflater.inflate(R.layout.fragment_main, container, false); 
      TextView textView = (TextView) rootView.findViewById(R.id.section_label); 
      textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); 
      return rootView; 

      } 

      @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
      if (getArguments().getInt(ARG_SECTION_NUMBER) == 1) { 
      View rootView = inflater.inflate(R.layout.fragment_sub_birds_you_seen, container, false); 
      return rootView; 
      } else if (getArguments().getInt(ARG_SECTION_NUMBER) == 2) { 
      View rootView = inflater.inflate(R.layout.fragment_sub_seed_eating, container, false); 
      return rootView; 

      } else if (getArguments().getInt(ARG_SECTION_NUMBER) == 3) { 
      View rootView = inflater.inflate(R.layout.fragment_sub_insect_eeters, container, false); 
      return rootView; 


      } else { 

      View rootView = inflater.inflate(R.layout.fragment_main, container, false); 
      TextView textView = (TextView) rootView.findViewById(R.id.section_label); 
      textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); 
      return rootView; 
      } 

      } 
      } 
      */ 

     } 

     /** 
     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to 
     * one of the sections/tabs/pages. 
     */ 
     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 MainActivity.PlaceholderFragment.newInstance(position + 1); 
      } 

      @Override 
      public int getCount() { 

       // Show 3 total pages. 
       return 3; 

      } 

      @Override 
      public CharSequence getPageTitle(int position) { 
       switch (position) { 
        case 0: 

         return "Birds you have seen"; 
        case 1: 
         return "Seed-eating"; 
        case 2: 
         return "insect eeters"; 

       } 
       return null; 
      } 
     } 
    } 
} 
のように見えます
Error:(89, 13) error: cannot find symbol class SectionsPagerAdapter 

私のアプリのGradleのは次の2つのonOptionsItemSelected私を持っているこの

apply plugin: 'com.android.application' 


android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

defaultConfig { 
    applicationId "com.madchallenge2016edwindaniel.upbirdwatchers" 
    minSdkVersion 16 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 

testCompile 'junit:junit:4.12' 



compile 'com.android.support:appcompat-v7:23.1.1' 
compile 'com.android.support:design:23.1.1' 
compile 'com.google.android.gms:play-services-auth:9.2.1' 
compile 'de.hdodenhof:circleimageview:1.3.0' 
compile 'com.squareup.picasso:picasso:2.5.2' 
compile 'com.google.android.gms:play-services-appindexing:9.2.1' 
compile 'com.android.support:support-v4:23.1.1' 
compile 'com.android.support:support-v13:+' 

} 
apply plugin: 'com.google.gms.google-services' 

答えて

0

のように見えますMainActivityで定義されている。そのうちの1つを削除し、クラスSectionsPagerAdapterはコンパイラによって検出されます。

関連する問題