2015-10-20 54 views
1

那是什麼,我有:TextInputLayout設計支持庫不顯示setCounterEnable()方法的android

TextInputLayout text1 = (TextInputLayout) view.findViewById(R.id.text1); 

我試圖做

text1.setCounterMaxLength(50); 

TextInputLayout沒有setCounterMaxLength()方法。我也試圖通過XML

<android.support.design.widget.TextInputLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
app:counterEnabled="true" 
app:counterMaxLength="10"> 
<android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:hint="Username" 
android:layout_centerHorizontal="true" 
android:layout_centerVertical="true" 
android:ems="10" 
android:hint="Username" /> 
</android.support.design.widget.TextInputLayout> 

它拋出下面的錯誤做到這一點:提前

compile 'com.android.support:design:23.0.1' 
compile 'com.android.support:appcompat-v7:23.0.1' 

感謝:

Error:(56) No resource identifier found for attribute 'counterEnabled' in package 
Error:(56) No resource identifier found for attribute 'counterMaxLength' in package 

我使用的gradle以下的依賴。

+0

嘗試'23.1.0',而不是'23.0.1' – CommonsWare

+0

謝謝,但我也嘗試過這一點。它也不起作用。我通過使用23.1.0得到了以下異常:錯誤:配置項目出現問題。 >配置項目'>時發生問題無法解析配置':debugCompile'的所有依賴關係。 >找不到com.android.support:design:23.1.0。 在以下位置搜索: https://jcenter.bintray.com/com/android/support/design/23.1.0/design-23.1.0.pom – Moon

+0

>無法找到com.android.support:design: 23.1.0。 在以下位置搜索: https://jcenter.bintray.com/com/android/support/design/23.1.0/design-23.1.0.pom https://jcenter.bintray.com/com/ android/support/design/23.1.0/design-23.1.0.jar – Moon

回答

2

首先,當您對問題進行重大更改時,請點擊問題下方的「編輯」鏈接並編輯問題。不要在評論中提供大量信息。

其次,您的Android儲存庫已過期,因爲23.1.0可用於所有標準支持庫。進入你的SDK管理器並更新Android Repository,在「Extras」區域的底部。

然後,您可以更新build.gradle以提取23.1.0,其中包含您的方法和屬性。

0

嘗試將構建工具更新到SDK管理器中的最新版本。之後將build.gradle更新爲compile 'com.android.support:support-v4:23.1.1'並重建gradle。

0

嘗試添加該在你android.support.design.widget.TextInputLayout,xmlns:app="http://schemas.android.com/apk/res-auto"

相關問題