【发布时间】:2016-11-09 18:32:41
【问题描述】:
我正在为我的 Android 应用程序实现图形签名捕获功能。
在网上我发现了一个完美运行的函数,它已经在我的代码中了。用户绘制他的签名,图像被正确保存!
现在我想添加这段代码:当调用onCreate 函数时,我想检查签名图像是否已经存在,如果存在,则加载它。通过此实现,用户可以检查自己的签名。
那可能吗?
非常感谢您的建议!提前致谢!
这是我的代码:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.firma_allievo);
tempDir = Environment.getExternalStorageDirectory().toString() + "/temp/"+corsok+"/";
ContextWrapper cw = new ContextWrapper(getApplicationContext());
current = tempDir + allievo + ".png"; // THIS IS THE PATH OF THE SIGNATURE IMAGE FILE
mypath= new File(current);
mContent = (LinearLayout) findViewById(R.id.linearLayout);
mSignature = new signature(this, null);
mSignature.setBackgroundColor(Color.WHITE);
mContent.addView(mSignature, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mClear = (Button)findViewById(R.id.clear);
mGetSign = (Button)findViewById(R.id.getsign);
mGetSign.setEnabled(true);
mCancel = (Button)findViewById(R.id.cancel);
mView = mContent;
mClear.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mSignature.clear();
}
});
mGetSign.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
boolean error = captureSignature();
if(!error){
mView.setDrawingCacheEnabled(true);
mSignature.save(mView);
Bundle b = new Bundle();
b.putString("status", "done");
Intent intent = new Intent();
intent.putExtras(b);
setResult(RESULT_OK,intent);
finish();
}
}
});
}
【问题讨论】:
标签: android image canvas png signature