- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我不知道这是什么错误。之前好好的,突然就坏了;我不知道为什么。在我刚刚更改我的图标之前,我已经将其更改回来但它仍然出错。请帮忙。如果是关于图像我认为不是,因为我在登录 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/
我正在使用 express并试图通过管道传输 req到远程服务器进行处理,然后通过 res 将结果通过管道传回客户端.它运行良好,但有时我认为 res由 connect-timeout 的操作结束,导
我正在尝试使用 fetch 进行简单的发布请求: const headers = new Headers({ Accept: 'application/json', 'Content-Type
我偶然发现了一个代码示例 here .引起我注意的行(跳过所有其他行): { ... void *res; ... s = pthread_join(tinfo[tnum].thread_id
我有一个 NodeJS 代码,使用请求模块向服务器发出请求。如果我使用“http.request”,代码工作正常,但在 res.on() 上显示错误使用请求来调用电话。以下是显示错误的部分: cons
我想知道这两种不同的方法在 expressjs 中是否相同? res.statusCode = 500; return res.json({ status: "error" }); 或者 r
我正在尝试在 Node.js 中制作简单的 ftp 客户端。一切正常,但我不知道如何在我的 Jade 模板中编写“singleFile.name”。 app.post('/ftp/login', fu
在frameworks/base下有这个xml文件。 /frameworks/base/core/res/res/layout/simple_dropdown_item_2line.xml 如何在我自
我是 odoo v8 的新手,我无法理解 res_partner 和 res_users 表之间的关系以及与 hr_employee 表之间的关系,它们都相关吗? 最佳答案 res.partner之间
我正在开发一个用于用户登录的小部件。基本上,当他们输入有效的帐户详细信息时,我希望它呈现相同的页面(使用 Handlebars )并声明“帐户已成功验证”之类的内容,然后 3 秒后重定向用户。 这是我
我有这种形式的数据 [ { device_id: '12335', timestamp: '2018-05-14T08:31:23.000Z', temperatur: 21,
我是 android 开发的新手,您可能会从我的问题中看出这一点。我发现我有一个 res/menu 文件夹和一个 res/layout 文件夹。它们都包含每个 Activity 的 XML 文件。但是
当我尝试按照指南中的说明在 res/menu 中创建新的菜单资源文件时,该文件夹不存在。 res/xml 也不是。有人可以告诉我如何解决这个问题吗?我尝试创建文件夹,但它不允许我这样做 最佳答案 如果
调用有什么区别: res.flushBuffer(); 对比 res.getOutputStream().flush(); 这些方法是否刷新相同的缓冲区? 如果是这样,你能告诉我这个缓冲区是如何由
为什么以下不起作用? res.send({ successMessage: 'Task saved successfully.' }); res.redirect('/'); 我基本上需要 A
我正在尝试确定是否可以同时调用 res.send(data) 和 res.render('reports')。 为了进一步详细解释,当我路由到“/reports”时,首先在我的服务器端我对返回 jso
app.get('/p/:tagId', function(req, res) { res.send("tagId is set to " + req.param("tagId")); }); 上
我在使用express.js 时遇到一些问题。我想在第一次请求时渲染我的模板,然后从路由中获取一些数据。我的路由如下所示: app.use(function (req, res, next) { r
我想根据屏幕尺寸加载 dimens.xml,但无论屏幕尺寸如何都使用相同的颜色。 我有以下目录结构 res res/values colors.xml res/values-small d
我有一张图片,rectangle.png。它的尺寸是 75x197。它位于 res/drawable 和 res/drawable-xhdpi。它在像这样的网格布局中显示了很多次(截图来自 Nexus
我很好奇返回响应和仅创建响应的区别。 我见过大量使用 return res.status(xxx).json(x) 的代码示例和res.status(xxx).json(x) . 谁能详细解释一下两者
我是一名优秀的程序员,十分优秀!