所以我正在从Web服务加载图像,但是图像的大小有时比其他图像更小或更大,当我将它们放入android中的ListView时,可视化看起来很傻.我想修改我的ImageView的大小,以便它只显示图像的一部分,如果它大于预设量.我已经尝试了所有我能想到的设置setMaxWidth/setMaxHeight,将scale类型设置为centerCrop,使用ClipableDrawable包装我的BitmapDrawable,使用Drawable.setBounds()进行设置.我已经尝试过设置XML并以编程方式设置,但都没有工作.我很惊讶设置最大宽度/高度没有做任何事情.下面是我在布局文件中使用ImageView定义的XML:
<ImageView android:id="@+id/recipeImage"
android:maxHeight="64px"
android:maxWidth="64px"
android:scaleType="centerCrop"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"/>
Run Code Online (Sandbox Code Playgroud)
但是,没有任何效果.
我正在使用Retrofit将图像上传到我的服务器.在这里,我需要为单个密钥上传多个图像.我已经尝试使用Postman Web客户端,它运行良好.这是一个截图.
以下是请求的键值对.
SurveyImage:[file1,file2,file3];
PropertyImage:文件
DRA:jsonBody
我试图用Retrofit做同样的事情.但图像没有上传到服务器.这是我的代码.
WebServicesAPI.java
public interface WebServicesAPI {
@Multipart
@POST(WebServices.UPLOAD_SURVEY)
Call<UploadSurveyResponseModel> uploadSurvey(@Part MultipartBody.Part surveyImage, @Part MultipartBody.Part propertyImage, @Part("DRA") RequestBody dra);
}
Run Code Online (Sandbox Code Playgroud)
这是上传文件的方法.
private void requestUploadSurvey() {
File propertyImageFile = new File(surveyModel.getPropertyImagePath());
RequestBody propertyImage = RequestBody.create(MediaType.parse("image/*"), propertyImageFile);
MultipartBody.Part propertyImagePart = MultipartBody.Part.createFormData("PropertyImage", propertyImageFile.getName(), propertyImage);
JSONObject requestBody = getRequestBody();
RequestBody draBody = null;
try {
draBody = RequestBody.create(MediaType.parse("text/plain"), requestBody.toString(1));
Log.d(TAG, "requestUploadSurvey: RequestBody : " + requestBody.toString(1));
} catch (JSONException e) {
e.printStackTrace();
}
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.setType(MultipartBody.FORM); …Run Code Online (Sandbox Code Playgroud) 我有两张桌子,一张是Information另一张桌子WorkForce
信息
劳动力
该TWF column在劳动力来获得id的信息,其假设回报1,但它的返回值0.如果id在信息是 5,twf应该是5了.
首先我使用它a来表示所选行的数量,然后将参数添加a到addWorkForce.在toast始终显示0.
a=addInformation(name,weather,date2,status,first1[1],last1[1]);
Toast.makeText(getApplicationContext(),a+"",Toast.LENGTH_LONG).show();
addWorkForce(Sub, NoP, NoH,a);
Run Code Online (Sandbox Code Playgroud)
addInformation函数
public long addInformation( final String name, final String weather, final String date2, final String status, final String timeIn, final String timeOut)
{
class AddInfo extends AsyncTask<String, Void, String> {
ProgressDialog loading;
@Override
protected void onPreExecute() {
super.onPreExecute();
loading = ProgressDialog.show(WorkDetailsTable.this, "Please Wait",null, true, true); …Run Code Online (Sandbox Code Playgroud) 在Food Tab中,我想实现这一目标
但我只能得到这个
如何增加JTextFieldFood Tab中的宽度?以下是我的代码
public class FoodOrdering {
static private JFrame frame;
static private JTextField textField;
static private GridBagConstraints gbc;
static private JLabel[] foodLabel;
static private JLabel[] labels;
static private JTextField[] qtyField;
static private JLabel[] foodImage;
static private File[] file;
private static final int ELEMENTS = 9;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FoodOrdering window = new FoodOrdering();
window.frame.setVisible(true);
} …Run Code Online (Sandbox Code Playgroud) 如何将图像添加到选项卡?目前,我能够标签移至底部,但对如何改变不知道 LL Tab1,LL Tab2,LL Tab3以icon.Am我在正确的道路上?任何帮助将不胜感激.
xml代码
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/ll_tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/ll_tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
<LinearLayout
android:id="@+id/ll_tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:background="@color/light_gray"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</TabHost>
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?非常感谢 !
我使用下面的代码插入Uri图像SQLite:
寄存器
private void insertData( String name,String pass, Uri image) throws SQLiteException {
database = mdb.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(MyDatabaseHelper.KEY_NAME, name);
cv.put(MyDatabaseHelper.KEY_PASSWORD, pass);
try {
database = mdb.getWritableDatabase();
InputStream iStream = getContentResolver().openInputStream(image);
byte[] inputData = Utils.getBytes(iStream);
cv.put(MyDatabaseHelper.KEY_IMAGE,inputData);
}catch(IOException ioe)
{
Log.e(TAG, "<saveImageInDB> Error : " + ioe.getLocalizedMessage());
}
database.insert(MyDatabaseHelper.TABLE_USER, null, cv);
Toast.makeText(getApplicationContext(),"Database Created",Toast.LENGTH_SHORT).show();
database.close();
}
Run Code Online (Sandbox Code Playgroud)
在我得到的时候Database Created,我假设数据库已成功创建并插入了数据.
在Login中,我想要SQLite根据用户名检索图像.
name = (EditText) findViewById(R.id.name);
name.addTextChangedListener(new TextWatcher() {
@Override
public void …Run Code Online (Sandbox Code Playgroud) 运行 pub get 后,我收到以下错误(第一次构建)
Because file_picker >=5.0.0 depends on ffi ^2.0.1 and open_file_safe 3.2.3 depends on ffi ^1.0.0, file_picker >=5.0.0 is incompatible with open_file_safe 3.2.3.
And because no versions of open_file_safe match >3.2.3 <4.0.0, file_picker >=5.0.0 is incompatible with open_file_safe ^3.2.3.
So, because app depends on both open_file_safe ^3.2.3 and file_picker ^5.2.2, version solving failed.
pub get failed (1; So, because app depends on both open_file_safe ^3.2.3 and file_picker ^5.2.2, version solving failed.)
Run Code Online (Sandbox Code Playgroud)
我尝试运行pub get命令并希望它能够成功运行而不会出现任何错误。