How to make Android Book App in Android Studio? Welcome to my Blog



Download 21,64 Kb.
Sana01.03.2020
Hajmi21,64 Kb.
#41278
Bog'liq
how to make android book app

How to make Android Book App in Android Studio?




   

 Welcome to my Blog



 Please Follow My Steps


Step 1:  Add Build.Gradule   

                             



Step 2:  Create 2 Empty Activities                     


1.MaainActivity

2.DescriptionActivity


Step 3:  Create 2 Classes                                   
1. Constant

2. TitleAdapter


Step 4:  Create 1 InterFace Class                       
1. CustomItemClickListner


Step 5:  Create 1 xml lyaout                               

1.title_layout
Step 6:  Convert Text into HTML                      

HTML5 Editor
Step 7:


Make Logo size is (432x432) and import it in batch drawable importer
Step 8:
Create Assets folder and paste xml file in assets folder
Step 9:
Replace the string names with your xml files name.
Build.Gradules

implementation'com.android.support:cardview-v7:28.0.0'

implementation'com.android.support:recyclerview-v7:28.0.0'
Constant.java
public class Constant
{
public static final String Java_Chapter1= "Java_Chapter1";

public static final String Java_Chapter2= "Java_Chapter2";

public static final String Java_Chapter3= "Java_Chapter3";

public static final String Java_Chapter4 = "Java_Chapter4";

public static final String Java_Chapter5 = "Java_Chapter5";

}
CustomItemClickListner.java

import android.view.View;

public interface CustomItemClickListner

{

public void onClickItem(View v, int position);



}


DescriptionActivity.java

import android.content.Context;


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
public class DescriptionActivity extends AppCompatActivity
{
private static final String TAG = "DescriptionActivity"; private Context mContext;
private WebView webView;
private Bundle extras;
@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);



setContentView(R.layout.activity_description);

mContext = DescriptionActivity.this;

webView= (WebView)findViewById(R.id.simpleView);

extras= getIntent().getExtras();

if(!extras.equals(null))

{

String data = extras.getString("titles");



Log.d(TAG, "onCreate: The coming data is"+data );

String url = "file:///android_asset/"+data+".html";

webView.loadUrl(url);

}}

}



MainActivity.java


import android.content.Intent;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.support.v7.widget.LinearLayoutManager;

import android.support.v7.widget.RecyclerView;

import android.view.View;

import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    private Context mContext;

ArrayList titleArrayList;

private RecyclerView mRecycleView;
    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        mContext= MainActivity.this;

        titleArrayList = new ArrayList ();


        titleArrayList.add(Constant.Java_Chapter1);

        titleArrayList.add(Constant.Java_Chapter2);

        titleArrayList.add(Constant.Java_Chapter3);

        titleArrayList.add(Constant.Java_Chapter4);

        titleArrayList.add(Constant.Java_Chapter5);

       mRecycleView=(RecyclerView)findViewById(R.id.Title_Recycler);

       mRecycleView.setHasFixedSize(true);

       mRecycleView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));


       TitleAdapter adapter = new TitleAdapter(mContext, titleArrayList, new CustomItemClickListner() {

           @Override

           public void onClickItem(View v, int position)

           {

               Intent deIntent = new Intent(mContext,DescriptionActivity.class);

               deIntent.putExtra("titles",titleArrayList.get(position) );

               startActivity(deIntent);

               Toast.makeText(mContext, "Clicked"+ titleArrayList.get(position), Toast.LENGTH_SHORT ).show();

           }

    });
mRecycleView.setAdapter(adapter);


    }


}

TitleAdapter.java
import android.content.Context;

import android.support.annotation.NonNull;

import android.support.v7.widget.RecyclerView;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.TextView;
import java.util.ArrayList;
public class TitleAdapter extends RecyclerView.Adapter

{

    private Context myContext;



    private ArrayList titlelist;

    private CustomItemClickListner clickListner;


    public TitleAdapter(Context myContext, ArrayList titlelist, CustomItemClickListner clickListner)

    {


        this.myContext = myContext;

        this.titlelist = titlelist;

        this.clickListner = clickListner;

    }
    @NonNull

    @Override

    public myViewHlder onCreateViewHolder(@NonNull final ViewGroup viewGroup, int i) {


        View view =LayoutInflater.from(myContext).inflate(R.layout.title_layout,viewGroup,false);

        final myViewHlder viewHlder= new myViewHlder(view);

   view.setOnClickListener(new View.OnClickListener() {

       @Override

       public void onClick(View v)

       {
       clickListner.onClickItem(v,viewHlder.getPosition());

       }

   });


        return viewHlder;

    }
    @Override

    public void onBindViewHolder(@NonNull myViewHlder myViewHlder, int i) {
       myViewHlder.titleText.setText(titlelist.get(i).replace("_"," "));
    }
    @Override

    public int getItemCount() {

        return titlelist.size();

    }
    public class myViewHlder extends RecyclerView.ViewHolder

{

TextView titleText;



    public myViewHlder(@NonNull View itemView) {

        super(itemView);

        titleText = (TextView) itemView.findViewById(R.id.stories_text);

    }


}
}

 activity_description




    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".DescriptionActivity">

   

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:id="@+id/simpleView"


        >
   




activity_main


    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">


            android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:id="@+id/Title_Recycler"

        />




title_layout.xml





xmlns:app="http://schemas.android.com/apk/res-auto"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="wrap_content">

    android:layout_width="wrap_content"

    android:layout_height="match_parent"

    app:cardCornerRadius="12dp"

    android:padding="5dp"

    android:layout_margin="5dp"

    >

    

        android:layout_width="match_parent"

        android:layout_height="wrap_content">


                    android:id="@+id/stories_image"

            android:layout_width="40dp"

            android:layout_height="28dp"

            android:src="@drawable/s1"
            />
        

            android:id="@+id/stories_text"

            android:layout_width="342dp"

            android:layout_height="wrap_content"

            android:layout_marginLeft="4dp"

            android:text="@string/story1_dillagi"

            android:textColor="#050505"

            android:textSize="16sp"

            android:text

            android:layout_marginStart="4dp" />






Download 21,64 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish