我正在为 RecyclerView 项目使用环绕 EditText 的 TextInputLayout 。我正在使用样式“Theme.AppCompat.Light.NoActionBar”。但我仍然收到错误“由:java.lang.IllegalArgumentException:此组件上的样式要求您的应用主题为 Theme.AppCompat(或后代)”。 但是,当我从 xml 中删除 TextInputLayout 时,应用程序运行良好。
这是我的 RecyclerView 项目(item_content_settings):
<?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="wrap_content"
android:orientation="horizontal"
android:weightSum="20">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="18"
android:padding="16dp">
<EditText
android:id="@+id/content_summary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="First Name"
android:inputType="text"
android:text="First Name And Last Name" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/pencil"
android:layout_width="0dp"
android:layout_height="16dp"
android:layout_gravity="center"
android:layout_margin="0dp"
android:layout_weight="2"
android:src="@drawable/pencil_edit" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的风格:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Base" …
Run Code Online (Sandbox Code Playgroud) android android-layout android-theme android-textinputlayout material-components-android
我正在RecyclerView
通过添加addOnScrollListener
功能来实现分页逻辑。
onScrolled
当 RecyclerView 适配器加载dy值为 0 时,该方法被调用一次。但是,当列表滚动时到达其末尾时,该onScrolled
方法不会被触发,而onScrollStateChanged
正确触发。
这是我的适配器:
HistoryAdapter(Context context, ArrayList<HistoryItem> items, RecyclerView recyclerView) {
inflater = LayoutInflater.from(context);
this.items = items;
preferences = PreferenceManager.getDefaultSharedPreferences(context);
this.context = context;
this.recyclerView = recyclerView;
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
Timber.w("onScrolled.. %s", dy);
if (dy > 0) {
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
Timber.e("totalItemCount: …
Run Code Online (Sandbox Code Playgroud) 当我由于窗户冻结而重启计算机后,遇到了一个真正的奇怪情况,我在Android Studio中将某些Java代码转换为一些奇怪的xml代码,而我编写的所有这些代码都丢失了!我两次遇到这种情况,这是我第一次遇到这种情况,因为最后一次提交后所做的更改很少,所以我将代码恢复为最后一次提交。但是这次这次更改在上一次提交之后是巨大的,我完全感到困惑!
以下是我的小代码之一的转换方式。
<component name="libraryTable">
<library name="Gradle: com.android.support:print:28.0.0@aar">
<ANNOTATIONS>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/print-28.0.0.aar/87cddf7f66cc3e6d635cf04e7292a008/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
Run Code Online (Sandbox Code Playgroud)
我的Android Studio版本:3.3.1
有什么方法可以找回我编写的代码吗?
任何帮助,将不胜感激。
我再次面对同样的情况。这是我用xml替换的另一个代码之一
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidConfiguredLogFilters">
<filters>
<filter>
<option name="logLevel" value="verbose" />
<option name="logMessagePattern" value="" />
<option name="logTagPattern" value="(MainActivity|Download|BooksFrag|Reading|BookPage|BookDetails|PageNumberPicker)" />
<option name="name" value="Unnamed-0" />
<option name="packageNamePattern" value="" />
<option name="pid" value="" />
</filter>
</filters>
</component>
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option …
Run Code Online (Sandbox Code Playgroud) android ×2