இந்த கட்டுரையில்
இரு எண்களின் கூட்டல் தொகை கண்டறியும் பயன்பாடு எவ்வாறு உருவாக்குவது என்று பார்ப்போம்.
Textview என்பது
எந்த ஒரு டெக்ஸ்டையும் டிஸ்பிளே செய்யப்பயன்படுகின்றது.Edittext என்பது எந்த மதிப்பு
அல்லது டெக்ஸ்டை உள்ளீடு செய்வதற்கு பயன்படுகின்றது.பட்டன் ஆனது அது கிளிக் செய்யப்படும்
பொழுது எந்த ஈவண்ட்கோடையும் இயக்குகின்றது.
இந்த கட்டுரையில்
இரண்டு டெக்ஸ்ட்வியூ டெக்ஸ்டை டிஸ்பிளே செய்வதற்கும் ஒரு டெக்ஸ்ட்வியூ அவுட்புட்டை
வெளியீடு செய்வதற்கும் பயன்படுகின்றது. இரண்டு எடிட்டெக்ஸ்ட் இரண்டு எண்களை இன்புட்
வாங்க பயன்படுகின்றது.மற்றும் ஒரு பட்டன் உள்ளது.
Design
Code
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter First
Number:-"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter Second
Number"
android:id="@+id/textView2"
android:layout_below="@+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_toRightOf="@+id/editText"
android:layout_toEndOf="@+id/editText" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sum of Two No"
android:id="@+id/button"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="52dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_result"
android:layout_below="@+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
பட்டனுக்கு
கிளிக் ஈவண்ட் ஆட் செய்யவும்.ஜாவா ஃபைலில் சம் மெத்தட் உருவாக்கி பட்டன் கிளிக் ஈவண்டுடன்
பைண்ட் செய்யவும்.
public void sum(View v) { //get the edit text EditText t1=(EditText)findViewById(R.id.editText); EditText t2=(EditText)findViewById(R.id.editText2); //convert value into int int x=Integer.parseInt(t1.getText().toString()); int y=Integer.parseInt(t2.getText().toString()); //sum these two numbers int z=x+y; //display this text to TextView TextView tv_data=(TextView)findViewById(R.id.tv_result); tv_data.setText("The sum is "+z); }
நன்றி.
முத்துகார்த்திகேயன்,மதுரை.
To learn any programming language contact
91 96293 29142
both direct and online class



No comments:
Post a Comment