以下是我的代码。我第一次得到 com.android.volley.NoConnectionError: java.io.InterruptedIOException,第二次它工作正常。服务器响应也很好,服务器端没有错误。
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
JsonObjectRequest request = new JsonObjectRequest(URL, null,
new Listener<JSONObject>() {
@Override
public void onResponse(JSONObject responseJsonObject) {
try {
if (responseJsonObject.has("user")
&& !responseJsonObject
.isNull("user")) {
user.jsonParser(responseJsonObject
.getJSONObject("user"));
}
} catch (JSONException exception) {
Toast.makeText(context, "Error Occured",
Toast.LENGTH_SHORT).show();
}
}
}, new ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
progressDialog.dismiss();
Log.d("Volley Error", volleyError.toString());
Toast.makeText(context, "Connectivity Error",
Toast.LENGTH_SHORT).show();
}
});
queue.add(request);
progressDialog.show();
queue.start();
Run Code Online (Sandbox Code Playgroud) 当我运行应用程序并单击工具栏图标时,我得到错误为"没有抽屉视图找到重力LEFT"
这是我的xml文件
main.xml中
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<android.support.v7.widget.RecyclerView
android:id="@+id/book_list_rv_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
<ListView
android:id="@+id/ListView1"
android:layout_width="241dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#333"
android:choiceMode="singleChoice"
android:divider="#666"
android:dividerHeight="1dp"
android:paddingLeft="15sp"
android:paddingRight="15sp" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这个id是活动java文件活动文件的代码片段
Toolbar mToolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// drawer
setSupportActionBar(mToolbar);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
mToolbar, R.string.app_name, R.string.app_name);
mDrawerLayout.setDrawerListener(mDrawerToggle);
Run Code Online (Sandbox Code Playgroud)