从edittext调用函数

时间:2015-06-17 10:47:06

标签: android android-edittext

我正在尝试从edittext调用一个函数。我使用extend activity时没有问题但是当我在{edit}文档上extending AppCompatActivity onClick方法时出错

我如何称呼它 -

<EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPersonName"
            android:hint="@string/date_hint"
            android:ems="10"
            android:id="@+id/editTextDate"
            android:layout_gravity="center_horizontal"
            android:background="@android:drawable/edit_text"
            android:onClick="buttonPlanYourWeek"
            android:focusable="false"
            android:clickable="true"/>

public void buttonPlanYourWeek(View view) {
    Intent i = new Intent(this, ListOfAgentActivity.class);
    finish();
    startActivity(i);
}

我收到错误:

Could not find a method planing_an_week(View) in the activity class android.support.v7.internal.widget.TintContextWrapper for onClick handler on view class android.support.v7.widget.AppCompatEditText with id 'buttonPlanYourWeek'

1 个答案:

答案 0 :(得分:1)

使用此代码

public void buttonPlanYourWeek() {
finish();
Intent i = new Intent(this, ListOfAgentActivity.class);    
startActivity(i);
}