কম্পিউটার টিউটোরিয়াল

অ্যান্ড্রয়েডে কাস্টম লিসেনার ইন্টারফেস তৈরি করা

কাস্টম লিসেনার ইন্টারফেস বাস্তবায়ন করা

এই উদাহরণটি দেখাবে কীভাবে নিজস্ব লিসেনার ইন্টারফেস তৈরি করে কম্পোনেন্ট間 যোগাযোগ করা যায়।

ধাপ ১: নতুন প্রজেক্ট তৈরি করুন

Android Studio-তে File → New Project নির্বাচন করুন।

ধাপ ২: লেআউট ফাইল (res/layout/activity_main.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="https://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:gravity="center"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="click"
        android:textSize="30sp" />
</LinearLayout>

ধাপ ৩: মেইন এক্টিভিটিতে কোড (src/MainActivity.java)

package com.example.myapplication;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends FragmentActivity implements sampleInterFace {
    sampleInterFace interFace;
    TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.text);
        this.interFace = (sampleInterFace) this;
        interFace.sample("Sairamkrishna Mammahe");
    }

    @Override
    public void sample(String text) {
        textView.setText(text);
    }
}

interface sampleInterFace {
    public void sample(String text);
}

অ্যাপ্লিকেশন চালানোর পদ্ধতি

অ্যাপ চালু করলে ইন্টারফেসের মাধ্যমে টেক্সট সেট হবে।

অ্যান্ড্রয়েডে কাস্টম লিসেনার ইন্টারফেস তৈরি করা

  1. অ্যান্ড্রয়েড অ্যাপে WebView তৈরির পদ্ধতি

  2. অ্যান্ড্রয়েড অ্যাপে TextToSpeech তৈরি করার পদ্ধতি

  3. Facebook-এ Android অ্যাপ তৈরি করার পদ্ধতি

  4. নিজস্ব অ্যান্ড্রয়েড উইজেট তৈরির উপায়