gpt4 book ai didi

Android Studio 找不到可绘制资源

转载 作者:太空宇宙 更新时间:2023-11-03 12:32:34 24 4
gpt4 key购买 nike

package com.sarham.kabs.fruity;

import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener{

private DrawerLayout drawerLayout;
private ListView listView;
private String[] planets;
private ActionBarDrawerToggle drawerListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawerLayout = (DrawerLayout)findViewById(R.id.drawerLayout);
listView = (ListView)findViewById(R.id.drawerListView);
planets = getResources().getStringArray(R.array.planets);
listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, planets));
listView.setOnItemClickListener(this);
drawerListener = new ActionBarDrawerToggle(this, drawerLayout, R.mipmap.ic_drawer, R.string.drawer_open, R.string.drawer_close){
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
Toast.makeText(MainActivity.this,"Drawer Open", Toast.LENGTH_LONG).show();
}

@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
Toast.makeText(MainActivity.this, "Drawer Closed", Toast.LENGTH_LONG).show();
}
};
drawerLayout.setDrawerListener(drawerListener);
}


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

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(this, planets[position]+" Was selected", Toast.LENGTH_LONG).show();
selectItem(position);
}
public void selectItem(int position){
listView.setItemChecked(position, true);
setTitle(planets[position]);
}
public void setTitle(String title){
getSupportActionBar().setTitle(title);
}
}

我正在 android studio 中做一个项目,我试图放置抽屉导航图标,但我收到此错误:“找不到符号 R.mipmap.if_drawer”, 我试过将它放在可绘制对象中,但对于符号 'R.drawable. 抛出相同的错误。 ic_drawer'

清理和重建后,我收到以下消息:

错误:(32, 26) 错误:找不到适合 ActionBarDrawerToggle(MainActivity,DrawerLayout,int,int,int) 的构造函数构造函数 ActionBarDrawerToggle.ActionBarDrawerToggle(Activity,Toolbar,DrawerLayout,T,int,int) 不适用(不能从参数实例化,因为实际和形式参数列表的长度不同)构造函数 ActionBarDrawerToggle.ActionBarDrawerToggle(Activity,DrawerLayout,Toolbar,int,int) 不适用(实参int不能通过方法调用转换为Toolbar)构造函数 ActionBarDrawerToggle.ActionBarDrawerToggle(Activity,DrawerLayout,int,int) 不适用(实际和形式参数列表的长度不同)其中 T 是类型变量:T extends Drawable,DrawerToggle declared in constructor ActionBarDrawerToggle(Activity,Toolbar,DrawerLayout,T,int,int)

最佳答案

请清理您的项目并重建

构建 > 清理项目然后构建 > 重建项目

关于Android Studio 找不到可绘制资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29181683/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com