Android的形式复位? [英] Android Form Reset?

查看:160
本文介绍了Android的形式复位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的计算器,有六个的EditText意见,并在用户输入数字进行简单的数学函数。这个程序将满足重复性任务,其中用户输入的信息,preSS提交按钮,答案显示在一个单独的TextView。

I have a simple calculator that has six EditText views where users will enter numbers to perform a simple math function. This app will satisfy a repetitive task wherein the users will enter the information, press the submit button and the answer is displayed in a separate textView.

我想添加一个简单的清除按钮,将重置表单,以便用户可以开始一个新的计算和EditText上的观点将再次展现自己的提示用户输入。

I want to add a simple 'clear' button that will reset the form so the users can begin a new calculation and the EditText views will show their hints for user input once again.

有一个重置功能型,将清除所有表单数据,并重新加载提示或我杀应用程序并重新启动?如果是这样,什么一个很好的起点,如何做到这一点?

Is there a 'reset' type function that will clear all of the form data and reload the hints or do I have to kill the app and start it again? If so, whats a good starting place for how to do this?

谢谢!

推荐答案

最基本的方式做,这是简单地重新设置您的的EditText 的意见。如果您有逻辑驱动这些领域的更新,则重置他们的空字符串并请求重新计算更新提示。

The most basic way to do this would be to simply reset your EditText views. If you have logic that drives the update of these fields, then resetting them to an empty String and requesting a "recalculation" to update the hints.

事情是这样的:

private void onClear()
{
    EditText firstField = (EditText)this.findById(R.id.firstField);
    EditText secondField = (EditText)this.findById(R.id.secondField);
    //...etc...
    if (firstField != null) firstField.setText("");
    if (secondField != null) secondField.setText("");

    updateHints();
}

private void updateHints()
{
    //Logic for your "hints"
}

这篇关于Android的形式复位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆