编辑文本格式掩码不显示 % 符号



我正试图在应用程序中创建一个阵营-put-de"%"结果。

问题是,我使用的Mask很简单,所以当我使用时,数字从1到999,"%"似乎也不会显示。

有人能帮我吗?

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import com.github.rtoshiro.util.format.MaskFormatter;
import com.github.rtoshiro.util.format.SimpleMaskFormatter;
import com.github.rtoshiro.util.format.pattern.MaskPattern;
import com.github.rtoshiro.util.format.text.MaskTextWatcher;
public class ActivityForm extends AppCompatActivity {
private EditText percentual;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity_form);
percentual = (EditText) findViewById(R.id.percentual_Id);
SimpleMaskFormatter simpleMaskPercentual = new SimpleMaskFormatter( " NNN% " );
MaskTextWatcher maskPercentual = new MaskTextWatcher(percentual, simpleMaskPercentual);
percentual.addTextChangedListener( maskPercentual );
}
}

您需要使用双百分号%%。有关更多详细信息,请访问在java 中显示百分比

最新更新