gpt4 book ai didi

android - 无法启动 Activity ComponentInfo android.content.res.Resources$NotFoundException : Resource ID

转载 作者:搜寻专家 更新时间:2023-11-01 08:21:23 25 4
gpt4 key购买 nike

我不知道这是什么错误。之前好好的,突然就坏了;我不知道为什么。在我刚刚更改我的图标之前,我已经将其更改回来但它仍然出错。请帮忙。如果是关于图像我认为不是,因为我在登录 Activity 中使用了图像但它很好

这是我的java

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

new daftarMahasiswa().execute();
}
public void pinjamKelas(){
LinearLayout pinjamkelas = (LinearLayout) findViewById(R.id.pinjam_kelas);
pinjamkelas.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, KelasActivity.class);
startActivity(intent);
}
});
}
class daftarMahasiswa extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Sedang menampilkan...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

@Override
protected String doInBackground(String... params) {
String link_url = "http://192.168.43.54/datapeminjamankelas/read_mahasiswa.php";
JSONParser jParser = new JSONParser();
JSONObject json = null;
try {
json = jParser.AmbilJson(link_url);
} catch (JSONException e) {
e.printStackTrace();
}
try {
str_json = json.getJSONArray("data");
for (int i = 0; i < str_json.length(); i++) {
JSONObject ar = str_json.getJSONObject(i);
String nim = ar.getString("nim").trim();
String nama = ar.getString("nama").trim();
String ruang = ar.getString("ruang").trim();
HashMap map = new HashMap();
map.put(in_nim, nim);
map.put(in_nama, nama);
map.put(in_ruang, ruang);
data_map.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
list = (ListView) findViewById(R.id.list);
adapter = new RuangAdapter(MainActivity.this, data_map);
list.setAdapter(adapter);
setListViewHeightBasedOnChildren(list);

list.setOnItemClickListener(new AdapterView.OnItemClickListener()

{
@Override public void onItemClick (AdapterView < ? > parent, View view,
int position, long id){
String nim = ((TextView) view.findViewById(R.id.txtNim)).getText().toString();
Intent i = new Intent(MainActivity.this, DetailPinjamActivity.class);
i.putExtra("lemparNIM", nim);
startActivity(i);
}
});
}
});
return null;
}

@Override
protected void onPostExecute(String s) {
pDialog.dismiss();
}

}

public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) return;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
int totalHeight = 0;
View view = null;
for (int i = 0; i < listAdapter.getCount(); i++) {
view = listAdapter.getView(i, view, listView);
if (i == 0)
view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));
view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += view.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}

这是我的xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#ecf0f1"
tools:showIn="@layout/app_bar_main">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="160dp"
android:orientation="horizontal"
android:layout_gravity="center">


<LinearLayout
android:id="@+id/pinjam_kelas"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/colorPrimary"
android:foreground="?attr/selectableItemBackground"
android:orientation="vertical"
android:layout_gravity="center"
android:layout_margin="10dp">

<ImageView
android:layout_width="wrap_content"
android:layout_height="100dp"
android:paddingTop="10dp"
android:src="@drawable/room" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pinjam Ruang kelas"
android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"
android:paddingBottom="10dp"/>
</LinearLayout>


</LinearLayout>



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kelas yang telah dipinjam:"
android:textSize="20dp"
android:textColor="@android:color/black"
android:layout_marginLeft="10dp"/>


<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Peminjam"
android:textSize="18dp"
android:layout_marginLeft="10dp"
android:textColor="@color/colorPrimary"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Kelas"
android:textSize="18dp"
android:gravity="right"
android:layout_marginRight="10dp"
android:textColor="@color/colorPrimary"/>
</LinearLayout>

<View
android:layout_margin="5dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>

<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</ListView>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Data Kosong"
android:textSize="20dp"
android:layout_gravity="center"/>

</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

这是我的错误

 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mqa.android.peminjamankelas, PID: 25294
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mqa.android.peminjamankelas/com.mqa.android.peminjamankelas.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f070059
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2855)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2930)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1619)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6683)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070059
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:209)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:91)
at android.content.res.Resources.getValue(Resources.java:1329)
at android.support.v7.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:234)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:755)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:87)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:128)
at android.support.v7.app.AppCompatDelegateImplV9.<init>(AppCompatDelegateImplV9.java:149)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:29)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:54)
at android.support.v7.app.AppCompatDelegateImplV23.<init>(AppCompatDelegateImplV23.java:31)
at android.support.v7.app.AppCompatDelegateImplN.<init>(AppCompatDelegateImplN.java:31)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:519)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:70)
at com.mqa.android.peminjamankelas.MainActivity.onCreate(MainActivity.java:47)
at android.app.Activity.performCreate(Activity.java:7046)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2930) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1619) 
at android.os.Handler.dispatchMessage(Handler.java:105) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6683) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) 

最佳答案

只需清理您的项目并尝试重建它。

关于android - 无法启动 Activity ComponentInfo android.content.res.Resources$NotFoundException : Resource ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50460220/

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