我是android的新手.所以我正在努力解决以下问题.
1. android:layout_width = "wrap_content"在EditText中设置后,它被垂直展开.
2. android:layout_width="180dp"在EditText中设置后,它被水平扩展.
有没有设置我的EditText固定?例如:如果要在EditText中键入长电子邮件地址,则文本的字体大小应基于长文本而不是EditText进行扩展而缩小.有没有可能完成这项任务?
这是我的代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.vadmin.myrx.SendReport">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Doctor Email"
android:textStyle="bold"
android:id="@+id/textView1"
android:layout_marginTop="75dp"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:hint="example@xyz.com"
android:padding="3dp"
android:background="@drawable/text_oval"
android:id="@+id/textView2"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Phone"
android:textStyle="bold"
android:id="@+id/textView3"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="44dp"
android:layout_below="@+id/textView1"
android:layout_alignRight="@+id/textView1"
android:layout_alignEnd="@+id/textView1" />
<EditText
android:layout_width="180dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:hint="+91 0000 000 000"
android:padding="3dp"
android:id="@+id/textView4"
android:layout_alignTop="@+id/textView3"
android:layout_alignLeft="@+id/textView2"
android:layout_alignStart="@+id/textView2"
android:background="@drawable/text_oval"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Report"
android:textStyle="bold"
android:id="@+id/textView5"
android:layout_marginTop="45dp" …Run Code Online (Sandbox Code Playgroud) 我想这是一个非常新手的问题,但我在Android上只花了两周时间.
我的问题是,我有一个使用引用R.array.NAME创建的StringArray
我想用StringArray中的值填充一个带有复选框的Dialog,但似乎我需要将它转换为CharSequence []所以我可以使用:setMultiChoiceItems
我找不到办法去做.
这是我的代码(无论如何我必须添加接受/取消按钮)
//我想从我这里得到这个(科目变量) StringArray R.array.NAME
final CharSequence[] subjects = {"Sports", "History", "Maths"};
final boolean[] states = {false, true, false};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMultiChoiceItems(subjects, states, new DialogInterface.OnMultiChoiceClickListener(){
public void onClick(DialogInterface dialogInterface, int item, boolean state) {
}
});
Run Code Online (Sandbox Code Playgroud)
非常感谢你们.
我尝试以传统的方式下载和导入它,但是在我这样做之后它不起作用.有人能告诉我哪里错了吗?
链接:http: //www.techrepublic.com/blog/software-engineer/teach-your-next-android-app-to-speak/ (我尝试下载整个项目)
我尝试使用Retrofit和gson库发出API请求,我按照本教程通过改造来制作我的API请求:http: //blog.robinchutaux.com/blog/a-smart-way-to-use-retrofit/但是我遇到错误.这是日志消息的不同部分:
Retrofit? java.lang.StackOverflowError at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:372)
...
API.ItemTypeAdapterFactory.create(ItemTypeAdapterFactory.java:20)
at com.google.gson.Gson.getAdapter(Gson.java:359)
Run Code Online (Sandbox Code Playgroud)
这是类ItemTypeAdapterFactory:
public class ItemTypeAdapterFactory implements TypeAdapterFactory {
public <T> TypeAdapter<T> create(Gson gson, final TypeToken<T> type) {
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
return new TypeAdapter<T>() {
public void write(JsonWriter out, T value) throws IOException {
delegate.write(out, value);
}
public T read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
if (jsonElement.isJsonObject()) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
if (jsonObject.has("content") && jsonObject.get("content").isJsonObject())
{
jsonElement …Run Code Online (Sandbox Code Playgroud)