سلام
برای تنظیم خصوصیات یک کامپوننت می توانیم از پالت attributes استفاده کنیم که کد نویسی را راحت می کند . سئوال دارم : برای اعمال محدودیت در وارد کردن عدد در یک textfield و نمایش یک error message از کدام قسمت باید استفاده کرد ( بدون کد نویسی مستقیم در فایل جاوا ) و چطور در کادر مخصوص به آن کد نویسی کرد ؟ ( عکس ضمیمه )
Capture - Copy.PNG
package com.example.saeed.prrrrrr14;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void btn_sum(View v) {
int aa = 0, bb = 0, sum;
TextView Txt_1 = (TextView) findViewById(R.id.editText);
aa = Integer.parseInt(Txt_1.getText().toString());
TextView Txt_2 = (TextView) findViewById(R.id.editText2);
bb = Integer.parseInt(Txt_2.getText().toString());
sum = aa * bb;
TextView Result = (TextView) findViewById(R.id.lblans);
Result.setText(Integer.toString(sum));
}
}