我制作了一个应用程序,在其中单击按钮时,我滑动了一个线性布局。滑动线性布局的代码工作正常,但问题是滑动时滞后。此外,我设置的滑动布局的高度看起来并不适用于所有屏幕尺寸(特别是在 Nexus 5 上)。请帮帮我
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_upload_add"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/add" />
<LinearLayout
android:id="@+id/ll_upload_options"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/choosefile_bg"
android:gravity="center"
android:orientation="vertical">
<pocketdocs.indiehustlers.com.pocketdocsv2.Utils.TextViewGeneral
android:id="@+id/tv_upload_gallery"
style="@style/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="5dp"
android:text="GALLERY"
android:textSize="20sp"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="@drawable/line" />
<pocketdocs.indiehustlers.com.pocketdocsv2.Utils.TextViewGeneral
android:id="@+id/tv_upload_camera"
style="@style/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:padding="5dp"
android:text="CAMERA"
android:textSize="20sp"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="@drawable/line" />
<pocketdocs.indiehustlers.com.pocketdocsv2.Utils.TextViewGeneral
android:id="@+id/tv_upload_file"
style="@style/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:padding="5dp"
android:text="FILE"
android:textSize="20sp"
android:visibility="visible" />
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) 我创建了一个应用程序,我允许用户从图库中选择图像或从相机拍照并上传该图像到Web服务器.这个代码工作正常.现在在其他屏幕上我从Web服务器下载图像并存储在SD卡中.如果从图库中选择图像,图像正在图像视图中显示,但如果从相机捕获图像,即使文件存在于图像视图中,图像也未显示在图像视图中SD卡
用于显示图像和从服务器下载的代码
private static class DownloadImage extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
String filePath = downloadFile("my web service");
return filePath;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (result.equalsIgnoreCase("")) {
ivProfilePic.setImageDrawable(context.getResources().getDrawable(R.drawable.user_default));
progressBar.setVisibility(View.GONE);
} else {
profilePicPath = result;
Bitmap bitmapProfilePic = BitmapFactory.decodeFile(profilePicPath);
ivProfilePic.setImageBitmap(bitmapProfilePic);
progressBar.setVisibility(View.GONE);
}
}
}
public static String downloadFile(String url, String dest_file_path) {
try {
File dest_file = new File(dest_file_path);
URL u = new URL(url); …Run Code Online (Sandbox Code Playgroud) 我正在使用gridview来显示一些图像.我做了代码,但我仍然没有得到任何图像
定制适配器
public class CustomAdapter extends BaseAdapter {
private Context context;
private int[] images;
public CustomAdapter(Context context, int[] images) {
this.context = context;
this.images = images;
}
@Override
public int getCount() {
return images.length;
}
@Override
public Object getItem(int position) {
return images[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.custom_trips_frag_row, parent, false);
// …Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序,其中我使用了sqlite db.I已成功创建表并将数据插入其中.但是当我尝试删除数据时,查询似乎不起作用.
码
public void deleteSubject(int Id) {
String query = "DELETE FROM " + TABLE_NAME + " WHERE " + DataBaseColumns.SUBJECT_ID + "=" + Id;
// String whereClause = DataBaseColumns.SUBJECT_ID + "=?";
database = openDb();
Cursor cursor = null;
try {
// result = database.delete(TABLE_NAME, whereClause, new String[Id]);
cursor = database.rawQuery(query, null);
} catch (SQLiteException e) {
Log.e("Error in delete Subjects", e.getMessage());
}
database = closeDb();
cursor.close();
}
Run Code Online (Sandbox Code Playgroud)