有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java我在google play store上的第一个应用向我展示

有人能帮我解决这个问题。我真的不明白这个错误

我在网上也发现了类似的问题,但发布的解决方案似乎都不管用。能帮我的人。 编辑:我已经在安卓工作室工作了。 My screenshot Other

package com.example.安卓.xxxxxxxxxxy;
  import 安卓.content.Intent;
    import 安卓.content.res.Configuration;
    import 安卓.media.MediaPlayer;
    import 安卓.net.Uri;
    import 安卓.support.v4.widget.DrawerLayout;
    import 安卓.support.v7.app.ActionBarDrawerToggle;
    import 安卓.support.v7.app.AppCompatActivity;
    import 安卓.os.Bundle;
    import 安卓.view.Menu;
    import 安卓.view.MenuItem;
    import 安卓.view.View;
    import 安卓.widget.AdapterView;
    import 安卓.widget.ArrayAdapter;
    import 安卓.widget.Button;
    import 安卓.widget.ListView;
    import 安卓.widget.Toast;
    import com.google.安卓.gms.ads.AdRequest;
    import com.google.安卓.gms.ads.AdView;

public class MainActivity extends AppCompatActivity {

private ListView mDrawerList;
private DrawerLayout mDrawerLayout;
private ArrayAdapter<String> mAdapter;
private ActionBarDrawerToggle mDrawerToggle;
private String mActivityTitle;

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

    mDrawerList = (ListView)findViewById(R.id.navList);mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
    mActivityTitle = getTitle().toString();

    addDrawerItems();
    setupDrawer();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);



    AdView adView = (AdView) findViewById(R.id.adView);

    AdRequest adRequest = new AdRequest.Builder()
            .setRequestAgent("安卓_studio:ad_template").build();

             // The firstbutton (song).

    assert adView != null;
    adView.loadAd(adRequest);

    final MediaPlayer happy_birthday_to_me = MediaPlayer.create(this, R.raw.happy_birthday_to_me);

    Button playsongmeow = (Button) this.findViewById(R.id.play_song_meow);

    assert playsongmeow != null;
    playsongmeow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            happy_birthday_to_me.start();

        }
    });

             // The secondbutton (song).

    assert adView != null;
    adView.loadAd(adRequest);

    final MediaPlayer birthday = MediaPlayer.create(this, R.raw.birthday);

    Button playsongmeoww = (Button) this.findViewById(R.id.play_song_meoww);

    assert playsongmeoww != null;
    playsongmeoww.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            birthday.start();

        }
    });


             // The thirdbutton (song).

    assert adView != null;
    adView.loadAd(adRequest);

    final MediaPlayer happy = MediaPlayer.create(this, R.raw.happy);

    Button playsongmeowww = (Button) this.findViewById(R.id.play_song_meowww);

    assert playsongmeowww != null;
    playsongmeowww.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            happy.start();

        }
    });


          // The fourthbutton (song).

    assert adView != null;
    adView.loadAd(adRequest);

    final MediaPlayer original = MediaPlayer.create(this, R.raw.original);

    Button playsongmeowwww = (Button) this.findViewById(R.id.play_song_meowwww);

    assert playsongmeowwww != null;
    playsongmeowwww.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            original.start();

        }
    });

}

private void addDrawerItems() {
    String[] osArray = {"Songs", "Photos", "Videos", "About"};
    mAdapter = new ArrayAdapter<String>(this, 安卓.R.layout.simple_list_item_1, osArray);
    mDrawerList.setAdapter(mAdapter);

    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(MainActivity.this, MainActivity.class);
            startActivity(intent);

            switch (position) {
                case 0: //Log History
                    Intent MainActivity = new Intent(MainActivity.this, MainActivity.class);
                    startActivity(MainActivity);
                    break;
                case 1: //Log History
                    Intent Photos = new Intent(MainActivity.this, Photos.class);
                    startActivity(Photos);
                    break;
                case 2: //Log History
                    Intent Videos = new Intent(MainActivity.this, Videos.class);
                    startActivity(Videos);
                    break;
                case 3: //Log History
                    Intent About = new Intent(MainActivity.this, About.class);
                    startActivity(About);
                default:
            }
        }
    });
}

private void setupDrawer() {
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {

        /** Called when a drawer has settled in a completely open state. */

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getSupportActionBar().setTitle("List Menu");
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        /** Called when a drawer has settled in a completely closed state. */

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getSupportActionBar().setTitle(mActivityTitle);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    // Sync the toggle state after onRestoreInstanceState has occurred.

    mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    mDrawerToggle.onConfigurationChanged(newConfig);
}

@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) {

            // Inflate your main_menu into the menu.

            int id = item.getItemId();

    switch (id){
        case R.id.about:


            Intent About = new Intent(MainActivity.this, About.class);
            startActivity(About);

            break;
    }

    switch (id) {
        case R.id.rate:

            // Open this Uri.

            Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=com.exafmpflle.安卓.happybirthdayyyy&hl=en"); // missing 'http://' will cause crashed
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);

            break;
    }

    switch (id){
        case R.id.privacy:

            // Open this Uri.

            Uri uri = Uri.parse("https://docs.google.com/document/d/1DEBh3j3LG5WaF9nT9Gl2hpswa3yD-36MfPhVo3S_p08/edit"); // missing 'http://' will cause crashed
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);

            break;
    }

    // Activate the navigation drawer toggle

    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

共 (1) 个答案

  1. # 1 楼答案

    错误似乎是说您覆盖的方法之一不存在。尝试重新检查要覆盖的方法的拼写

    如果这有帮助,请考虑将这篇文章标记为答案。