Welcome to

w3study.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

8. Event Handling in Android in Hindi

Event Handling का मतलब है कि जब User किसी UI Component (जैसे Button, EditText, या Checkbox) से Interaction करता है, तो उस Interaction को सही तरीके से पकड़ने और Response देने की प्रक्रिया। Android में Event Handling का मुख्य उद्देश्य यह है कि User Actions (click, touch, text change, etc.) के बाद App उस Action का सही Response दे सके।

Event Handling का तरीका

Event Listener:

Event Handling के लिए Event Listener का उपयोग किया जाता है, जो किसी specific Action (जैसे Button का Click) पर Trigger होता है।

उदाहरण के लिए: OnClickListener का उपयोग हम Button के Click Event को Handle करने के लिए करते हैं।

Callbacks:

Event Listener के द्वारा जब Event Trigger होता है, तो Callback method को Call किया जाता है।

Types of Event Handling

1. View Event Handling:

View Event Handling का मतलब है कि जब User किसी UI Component (जैसे Button, EditText, RadioButton) से Interaction करता है, तो उसका Event Handle करना।

उदाहरण: Button का Click Event, TextView का Touch Event, etc.

2. Touch Event Handling:

Touch Event में Tap, Swipe, Pinch, Zoom जैसे Actions होते हैं। TouchEvent का उपयोग किसी View पर User की Touch Actions को Detect करने के लिए किया जाता है।

3. Gesture Event Handling:

Gesture Events में Swipe, Pinch, Double Tap जैसी Multi-touch या Complex Touch Actions होती हैं। इन्हें handle करने के लिए Android में Gesture Detection का प्रयोग होता है।

  • Layouts in Hindi

  • Development of Android Applications Notes in Hindi


  • Request:

    हैलो दोस्तों! उम्मीद करता हूं आपको हमारा यह content/post पसंद आया होगा। अगर आपको हमारा ये content/post पसंद आई हो तो अपने दोस्तों के पास भी share करे। और अगर आपको कोई problem या कोई specific content हिन्दी में चाहिए है तो आप हमें नीचे दिए गए Email या whatsapp number के जरिए बता सकते है।

    अगर आप CCC/diploma/polytechnic/MCA/BCA etc कर रहे है तो ये website स्पेशली आपके लिए ही है, जो student हिंदी में पढ़ाई करते है।

    Contact Us

    Email: deepanshuranjan8057@gmail.com

    Whatsapp: +91 8057754706



    Follow Us

    Facebook Logo    Instagram Logo