parent
4e92a2d41d
commit
9c7b29c63b
@ -0,0 +1,69 @@ |
||||
package com.community.pocket.ui.main.ui.forum; |
||||
|
||||
import android.text.Editable; |
||||
import android.text.Html; |
||||
import android.text.TextWatcher; |
||||
import android.view.View; |
||||
import android.widget.EditText; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.annotation.IdRes; |
||||
|
||||
import com.community.pocket.R; |
||||
|
||||
/** |
||||
* 提示正文输入字数 |
||||
*/ |
||||
public class ShowWordCount { |
||||
|
||||
@IdRes |
||||
private int[] ids; |
||||
|
||||
private View view; |
||||
|
||||
private EditText postContent; |
||||
|
||||
public ShowWordCount(int[] ids, int contentId, View view) { |
||||
this.ids = ids; |
||||
this.view = view; |
||||
this.postContent = view.findViewById(contentId); |
||||
} |
||||
|
||||
/** |
||||
* 设置计数 |
||||
*/ |
||||
private void setCount() { |
||||
String text = view.getContext().getString(R.string.post_content_count, postContent.length(), view.getContext().getResources().getInteger(R.integer.post_content)); |
||||
|
||||
for (int id : ids) { |
||||
TextView textView = view.findViewById(id); |
||||
textView.setText(Html.fromHtml(text)); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 提示正文字数 |
||||
*/ |
||||
public void showCount() { |
||||
|
||||
setCount(); |
||||
|
||||
postContent.addTextChangedListener(new TextWatcher() { |
||||
@Override |
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onTextChanged(CharSequence s, int start, int before, int count) { |
||||
setCount(); |
||||
} |
||||
|
||||
@Override |
||||
public void afterTextChanged(Editable s) { |
||||
|
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,18 +1,80 @@ |
||||
package com.community.pocket.ui.main.ui.visitor; |
||||
|
||||
import android.os.Build; |
||||
import android.os.Bundle; |
||||
import android.view.View; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.AutoCompleteTextView; |
||||
import android.widget.Spinner; |
||||
import android.widget.Toast; |
||||
|
||||
import androidx.annotation.NonNull; |
||||
import androidx.annotation.Nullable; |
||||
import androidx.annotation.RequiresApi; |
||||
|
||||
import com.community.pocket.R; |
||||
import com.community.pocket.ui.main.TestMainFragment; |
||||
import com.community.pocket.ui.BaseFragment; |
||||
import com.community.pocket.ui.main.ui.forum.ShowWordCount; |
||||
|
||||
import org.xutils.view.annotation.ContentView; |
||||
import org.xutils.view.annotation.Event; |
||||
import org.xutils.view.annotation.ViewInject; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* 访客预约界面 |
||||
*/ |
||||
@ContentView(R.layout.visitor_appointment_fragment) |
||||
public class VisitorAppointmentFragment extends TestMainFragment { |
||||
public class VisitorAppointmentFragment extends BaseFragment { |
||||
|
||||
//搜索预约住户
|
||||
@ViewInject(R.id.appointment) |
||||
private AutoCompleteTextView appointment; |
||||
|
||||
@ViewInject(R.id.choose_time) |
||||
private Spinner spinner; |
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
||||
@Override |
||||
protected int viewId() { |
||||
return R.id.text_apppointment; |
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
||||
super.onViewCreated(view, savedInstanceState); |
||||
ShowWordCount showWordCount = new ShowWordCount(new int[]{R.id.show_word_top, R.id.show_word_bottom}, R.id.notes, view); |
||||
showWordCount.showCount(); |
||||
initSearch(); |
||||
initChooseTime(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 搜索框 |
||||
*/ |
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
||||
private void initSearch() { |
||||
//TODO 设置数据源数组
|
||||
String[] arrays = {"abc", "abcde", "aef2", "fff", "asdfa"}; |
||||
|
||||
// 设置适配器
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(Objects.requireNonNull(this.getContext()), android.R.layout.simple_list_item_1, arrays); |
||||
// 将适配器与当前AutoCompleteTextView控件绑定
|
||||
appointment.setAdapter(adapter); |
||||
} |
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
||||
private void initChooseTime() { |
||||
//TODO 设置数据源数组
|
||||
String[] arrays = {"abc", "efg", "aef2", "fff", "asdfa"}; |
||||
// 设置适配器
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(Objects.requireNonNull(this.getContext()), android.R.layout.simple_list_item_1, arrays); |
||||
spinner.setAdapter(adapter); |
||||
} |
||||
|
||||
/** |
||||
* 提交预约信息 |
||||
*/ |
||||
@Event(value = R.id.submit) |
||||
private void submit(View view) { |
||||
Toast.makeText(view.getContext(), R.string.submit_appointment, Toast.LENGTH_SHORT).show(); |
||||
} |
||||
} |
||||
|
@ -1,13 +1,77 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<FrameLayout 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" |
||||
tools:context=".ui.main.ui.visitor.VisitorAppointmentFragment"> |
||||
|
||||
<TextView |
||||
android:id="@+id/text_apppointment" |
||||
<androidx.constraintlayout.widget.ConstraintLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" /> |
||||
android:layout_height="wrap_content" |
||||
android:layout_gravity="center_vertical"> |
||||
|
||||
<AutoCompleteTextView |
||||
android:id="@+id/appointment" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:completionThreshold="1" |
||||
android:gravity="center" |
||||
android:hint="@string/prompt_appointment" |
||||
app:layout_constraintBottom_toTopOf="@+id/choose_time" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toTopOf="parent" /> |
||||
|
||||
<Spinner |
||||
android:id="@+id/choose_time" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@+id/appointment" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/show_word_top" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/choose_time" /> |
||||
|
||||
<EditText |
||||
android:id="@+id/notes" |
||||
android:layout_width="0dp" |
||||
android:layout_height="@dimen/size_200" |
||||
android:background="@drawable/border" |
||||
android:ems="15" |
||||
android:gravity="start|top" |
||||
android:hint="@string/prompt_input_notes" |
||||
android:importantForAutofill="no" |
||||
android:inputType="textMultiLine" |
||||
android:maxLength="@integer/post_content" |
||||
android:maxLines="@integer/post_content_maxLines" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/show_word_top" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/show_word_bottom" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/notes" /> |
||||
|
||||
<Button |
||||
android:id="@+id/submit" |
||||
android:layout_width="0dp" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="8dp" |
||||
android:text="@string/submit_appointment" |
||||
app:layout_constraintEnd_toEndOf="parent" |
||||
app:layout_constraintStart_toStartOf="parent" |
||||
app:layout_constraintTop_toBottomOf="@id/show_word_bottom" /> |
||||
</androidx.constraintlayout.widget.ConstraintLayout> |
||||
</FrameLayout> |
Loading…
Reference in new issue