deepeweb.github.io

Android UI Components in Hindi

Android में UI (User Interface) Components का उपयोग Screen पर Elements (जैसे Button, TextView, ImageView, EditText आदि) को दिखाने और User Interaction को Handle करने के लिए किया जाता है।

1. TextView (text दिखाने के लिए)

Example (TextView in XML)

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello, Android!"
    android:textSize="20sp"
    android:textColor="#000000" />

Example (Java Code में Text Set करना)

TextView textView = findViewById(R.id.textView);
textView.setText("Welcome to Android!");

2. Button (buttom पर click करने के लिए)

Button Android का एक सबसे Common UI Component है, जिसका उपयोग User से Interaction के लिए किया जाता है। जब User किसी Button को Tap या Click करता है, तो एक Action Trigger होता है, जैसे:

Android में Button को XML (UI Design) और Java/Kotlin (Event Handling) में Define किया जाता है।

Example (Button in XML)

<Button
    android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Click Me" />

Example (Java Code में Button का Event Handle करना)

Button button = findViewById(R.id.button);
button.setOnClickListener(v -> {
    Toast.makeText(MainActivity.this, "Button Clicked!", Toast.LENGTH_SHORT).show();
});

3. EditText (User से Text Input लेने के लिए)

Example (EditText in XML)

<EditText
    android:id="@+id/editText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Enter your name" />

Example (Java Code में Text को Read करना)

EditText editText = findViewById(R.id.editText);
String userInput = editText.getText().toString();
Toast.makeText(MainActivity.this, "You entered: " + userInput, Toast.LENGTH_SHORT).show();

4. RadioButton (Multiple Options में से एक चुनने के लिए)

Example (RadioButton in XML)

<RadioGroup
    android:id="@+id/radioGroup"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <adioButton
        android:id="@+id/radioMale"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Male" />

    <RadioButton
        android:id="@+id/radioFemale"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Female" />
</RadioGroup>

Example (Java Code में Selection को Read करना)

RadioGroup radioGroup = findViewById(R.id.radioGroup);
int selectedId = radioGroup.getCheckedRadioButtonId();
RadioButton selectedRadioButton = findViewById(selectedId);
Toast.makeText(MainActivity.this, "Selected: " + selectedRadioButton.getText(), Toast.LENGTH_SHORT).show();

5. CheckBox (Multiple Options Select करने के लिए)

Example (CheckBox in XML)

<CheckBox
    android:id="@+id/checkBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Accept Terms & Conditions" />

Example (Java Code में CheckBox को Handle करना)

CheckBox checkBox = findViewById(R.id.checkBox);
if (checkBox.isChecked()) {
    Toast.makeText(MainActivity.this, "Checkbox is Checked!", Toast.LENGTH_SHORT).show();
}

6. ImageView (Images को Show करने के लिए)

ImageView का उपयोग Screen पर Images Show करने के लिए किया जाता है।

Example (ImageView in XML)

<ImageView
    android:id="@+id/imageView"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:src="@drawable/sample_image" />

Example (Java Code में Image Change करना)

ImageView imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.new_image);

7. ProgressBar (Loading Show करने के लिए)

ProgressBar का उपयोग तब किया जाता है जब कोई Task (जैसे File Downloading, Data Loading) चल रहा हो।

दो प्रकार के ProgressBar होते हैं:

Example (ProgressBar in XML)

<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone" />

Example (Java Code में ProgressBar Show/Hide करना)

ProgressBar progressBar = findViewById(R.id.progressBar);
progressBar.setVisibility(View.VISIBLE);  // Show ProgressBar
progressBar.setVisibility(View.GONE);     // Hide ProgressBar



Request

अगर आपको यह article useful या interesting लगा हो, तो please इसे अपने dosto aur family ke साथ जरूर share करें। आपका एक छोटा सा कदम हमें और अच्छा content बनाने के लिए motivate करता है। Thank you!

ध्यान दें कि इस page पर आपको कुछ ads भी देखने को मिल सकते हैं। इसके लिए हम आपसे माफी चाहते हैं। हम इस content को तैयार करने में काफी मेहनत और time लगाते हैं, ताकि आपको valuable जानकारी मिल सके। इन्हीं ads की मदद से हम ये काम continue कर पाते हैं।

आपके support और understanding के लिए दिल से धन्यवाद।





Ad
Ad


Ad
Ad

Follow Us

Facebook Logo    Instagram Logo