Android 在TextInputLayout中添加/删除编辑文本
我们已经有一个EditText,只能有一个 我已经为我的应用程序(LoginFragment)构建了一个片段,它处理两种主要的身份验证模式;即登录并注册用户。有一个按钮允许用户在“登录模式”和“注册”模式之间切换。每个“模式”都有一些其他模式不需要的附加视图。因此,有必要在切换模式时添加和删除视图 我在TextInputLayout布局中使用EditText视图。当我执行以下操作时,我的应用程序崩溃:Android 在TextInputLayout中添加/删除编辑文本,android,android-layout,android-view,android-design-library,android-textinputlayout,Android,Android Layout,Android View,Android Design Library,Android Textinputlayout,我们已经有一个EditText,只能有一个 我已经为我的应用程序(LoginFragment)构建了一个片段,它处理两种主要的身份验证模式;即登录并注册用户。有一个按钮允许用户在“登录模式”和“注册”模式之间切换。每个“模式”都有一些其他模式不需要的附加视图。因此,有必要在切换模式时添加和删除视图 我在TextInputLayout布局中使用EditText视图。当我执行以下操作时,我的应用程序崩溃: 以编程方式添加EditText 以编程方式删除EditText 以编程方式添加编辑文本->崩
- 以编程方式添加EditText
- 以编程方式删除EditText
- 以编程方式添加编辑文本->崩溃
java.lang.IllegalArgumentException: We already have an EditText, can only have one
at android.support.design.widget.TextInputLayout.setEditText(TextInputLayout.java:166)
at android.support.design.widget.TextInputLayout.addView(TextInputLayout.java:155)
at android.view.ViewGroup.addView(ViewGroup.java:3985)
at android.view.ViewGroup.addView(ViewGroup.java:3961)
at com.mydomain.myapp.fragments.LoginFragment.showActivateAccountViews(LoginFragment.java:317)
这来自android.support.design.widget.TextInputLayout,它有一个内部私有EditText变量,在添加视图时设置该变量(下面的源代码)。似乎当我第二次尝试将视图添加到TextInputLayout时,mEditText变量已经设置好了。该类没有自己的.removeView()方法,所以我不知道该如何删除它
我怀疑我错误地删除了EditText视图,但无法找出我做错了什么。我也读过其他一些关于删除视图的堆栈溢出文章,但是这些方法也没有解决这个问题
- 加入一项意见—
- 删除视图-
...
import android.support.design.widget.TextInputLayout;
import android.widget.EditText;
public class LoginFragment extends Fragment {
private RelativeLayout mContainer;
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_login, container, false);
mContainer = ((RelativeLayout) view.findViewById(R.id.login_container));
showLoginViews();
LayoutTransition layoutTransition = mContainer.getLayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
return view;
}
/**
* Show the view elements for Login mode
*/
private void showLoginViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the button for the primary action
Button loginButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
...
// Configure the toggle button to navigate to Activate Account mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showActivateAccountViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_activate_account));
// Hide the Member ID EditText
((TextInputLayout)mContainer.findViewById(R.id.member_id_inputlayout)).removeView(mContainer.findViewById(R.id.editText_member_id_field));
}
/**
* Show view elements for Activate Account mode
*/
private void showActivateAccountViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the primary button for the primary action - Activate Account
Button activateAccountButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
...
// Add the Member ID EditText
((TextInputLayout)mContainer.findViewById(R.id.member_id_inputlayout)).addView(li.inflate(R.layout.login_member_id_element_layout, (ViewGroup)mContainer.findViewById(R.id.member_id_inputlayout), false));
// Configure the toggle button to navigate to Login mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showLoginViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_login));
}
...
}
import android.support.design.widget.TextInputLayout;
import android.widget.EditText;
public class LoginFragment extends Fragment {
private RelativeLayout mContainer;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_login, container, false);
mContainer = ((RelativeLayout) view.findViewById(R.id.login_container));
showLoginViews();
LayoutTransition layoutTransition = mContainer.getLayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
return view;
}
/**
* Show the view elements for Login mode
*/
private void showLoginViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the toggle button to navigate to Activate Account mode
s TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showActivateAccountViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_activate_account));
// Hide the Member ID EditText
((LinearLayout)mContainer.findViewById(R.id.member_id_holderlayout)).removeView(mContainer.findViewById(R.id.member_id_inputlayout));
}
/**
* Show view elements for Activate Account mode
*/
private void showActivateAccountViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the primary button for the primary action - Activate Account
Button activateAccountButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
// Add the Member ID EditText
((LinearLayout)mContainer.findViewById(R.id.member_id_holderlayout)).addView(li.inflate(R.layout.login_member_id_element_layout, (ViewGroup) mContainer.findViewById(R.id.member_id_inputlayout), false));
// Configure the toggle button to navigate to Login mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showLoginViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_login));
}
}
login\u member\u id\u element\u layout.xml
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mydomain.myapp.fragments.LoginFragment">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<!--placeholder layout with params for activate account elements-->
<android.support.design.widget.TextInputLayout
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- a view can be added here-->
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/button_login_fragment_primary_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_inputlayout"
android:text="@string/action_login" />
<!-- Toggle button for Login/Activate Account-->
<TextView
android:id="@+id/button_toggle_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_activate_account" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--placeholder for TextInputLayout to be dynamically added at runtime-->
<LinearLayout
android:id="@+id/member_id_holderlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- a login_member_id_element_layout can be dynamically added/removed here at runtime-->
</LinearLayout>
<!--TextInputLayout for static fields, the EditText is not removed at runtime-->
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/member_id_holderlayout">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawablePadding="@dimen/edittext_drawable_padding"
android:drawableStart="?emailIcon"
android:focusable="true"
android:hint="Email"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
恭喜,您(可能?)发现了一个可能的bug(或者我应该说删除TextInputLayout
的EditText
?)时出现了非预期行为)
您可以看到removeView()
是来自ViewGroup的一个方法。它从视图组的子视图数组中删除视图
,但不删除InputTextLayout
对编辑文本的引用
那我该怎么办
您必须扩展TextInputLayout
并创建自己的方法,将super.mEditText
设置为null
。问题是,您仍然需要调用这两个方法,因为仅将布局
引用设置为null可能会在应用程序的整个生命周期中将旧布局保留在内存中。com.android.support.design库(v22.2.1)中似乎存在限制。不能在运行时直接删除EditText,然后将其添加到TextInputLayout。你可以把这只虫子当明星
我已经想出了解决这个问题的办法。我修改了xml布局,以便在运行时不从TextInputLayout中添加/删除EditText视图(这不起作用),而是将TextInputLayout本身添加/删除到LinearLayout保持器中。使用此解决方案,我们永远不需要从TextInputLayout中实际删除EditText
关于这个解决方案,唯一需要注意的是,它使您的视图层次结构比需要的更深一层。因此,如果您已经有UI性能问题,请记住这一点。如果您在阅读本文时发现com.android.support.design v22.2.1版本可用,则可能需要检查此问题是否已得到解决
否则,请参阅下面的示例代码以了解我的解决方案实现
LoginFragment.java
...
import android.support.design.widget.TextInputLayout;
import android.widget.EditText;
public class LoginFragment extends Fragment {
private RelativeLayout mContainer;
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_login, container, false);
mContainer = ((RelativeLayout) view.findViewById(R.id.login_container));
showLoginViews();
LayoutTransition layoutTransition = mContainer.getLayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
return view;
}
/**
* Show the view elements for Login mode
*/
private void showLoginViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the button for the primary action
Button loginButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
...
// Configure the toggle button to navigate to Activate Account mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showActivateAccountViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_activate_account));
// Hide the Member ID EditText
((TextInputLayout)mContainer.findViewById(R.id.member_id_inputlayout)).removeView(mContainer.findViewById(R.id.editText_member_id_field));
}
/**
* Show view elements for Activate Account mode
*/
private void showActivateAccountViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the primary button for the primary action - Activate Account
Button activateAccountButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
...
// Add the Member ID EditText
((TextInputLayout)mContainer.findViewById(R.id.member_id_inputlayout)).addView(li.inflate(R.layout.login_member_id_element_layout, (ViewGroup)mContainer.findViewById(R.id.member_id_inputlayout), false));
// Configure the toggle button to navigate to Login mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showLoginViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_login));
}
...
}
import android.support.design.widget.TextInputLayout;
import android.widget.EditText;
public class LoginFragment extends Fragment {
private RelativeLayout mContainer;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_login, container, false);
mContainer = ((RelativeLayout) view.findViewById(R.id.login_container));
showLoginViews();
LayoutTransition layoutTransition = mContainer.getLayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
return view;
}
/**
* Show the view elements for Login mode
*/
private void showLoginViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the toggle button to navigate to Activate Account mode
s TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showActivateAccountViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_activate_account));
// Hide the Member ID EditText
((LinearLayout)mContainer.findViewById(R.id.member_id_holderlayout)).removeView(mContainer.findViewById(R.id.member_id_inputlayout));
}
/**
* Show view elements for Activate Account mode
*/
private void showActivateAccountViews() {
LayoutInflater li = (LayoutInflater)getActivity().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
// Configure the primary button for the primary action - Activate Account
Button activateAccountButton = (Button)mContainer.findViewById(R.id.button_login_fragment_primary_action);
// Add the Member ID EditText
((LinearLayout)mContainer.findViewById(R.id.member_id_holderlayout)).addView(li.inflate(R.layout.login_member_id_element_layout, (ViewGroup) mContainer.findViewById(R.id.member_id_inputlayout), false));
// Configure the toggle button to navigate to Login mode
TextView toggleButton = (TextView)mContainer.findViewById(R.id.button_toggle_mode);
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LoginFragment.this.showLoginViews();
}
});
toggleButton.setText(getResources().getString(R.string.action_login));
}
}
login\u member\u id\u element\u layout.xml
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mydomain.myapp.fragments.LoginFragment">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<!--placeholder layout with params for activate account elements-->
<android.support.design.widget.TextInputLayout
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- a view can be added here-->
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/button_login_fragment_primary_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_inputlayout"
android:text="@string/action_login" />
<!-- Toggle button for Login/Activate Account-->
<TextView
android:id="@+id/button_toggle_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_activate_account" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--placeholder for TextInputLayout to be dynamically added at runtime-->
<LinearLayout
android:id="@+id/member_id_holderlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- a login_member_id_element_layout can be dynamically added/removed here at runtime-->
</LinearLayout>
<!--TextInputLayout for static fields, the EditText is not removed at runtime-->
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/member_id_holderlayout">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawablePadding="@dimen/edittext_drawable_padding"
android:drawableStart="?emailIcon"
android:focusable="true"
android:hint="Email"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
login_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.mydomain.myapp.fragments.LoginFragment">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<!--placeholder layout with params for activate account elements-->
<android.support.design.widget.TextInputLayout
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- a view can be added here-->
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/button_login_fragment_primary_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/password_inputlayout"
android:text="@string/action_login" />
<!-- Toggle button for Login/Activate Account-->
<TextView
android:id="@+id/button_toggle_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/action_activate_account" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/member_id_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText_member_id_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/member_id" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/login_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--placeholder for TextInputLayout to be dynamically added at runtime-->
<LinearLayout
android:id="@+id/member_id_holderlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- a login_member_id_element_layout can be dynamically added/removed here at runtime-->
</LinearLayout>
<!--TextInputLayout for static fields, the EditText is not removed at runtime-->
<android.support.design.widget.TextInputLayout
android:id="@+id/email_inputlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/member_id_holderlayout">
<EditText
android:id="@+id/editText_email_field"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawablePadding="@dimen/edittext_drawable_padding"
android:drawableStart="?emailIcon"
android:focusable="true"
android:hint="Email"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
我实际上已经尝试过了,但是,mEditText被声明为私有,这样做打破了面向对象编程的封装规则。我应该把声明包含在原始帖子的代码片段中,包括现在。我没想到。可能是扩展LinearLayout
并复制TextInputLayout
的整个源代码,并声明一个setEditText()
方法?@MauriceGavin有结果吗?我针对该问题提出了错误报告: