Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Thursday, 8 March 2018

ANDROID TAB LAYOUT Swipe Views WITH FRAGMENT USE TAB ADAPTER ARRAY LIST & COUNTER


TAB LAYOUT IN ANDROID 

EXAMPLE YOU TUBE , AND MORE APPLICATION USE TAB VIEW



Swipe Views. You can create swipe views in your app using the ViewPager widget, available in the STUDIO. The ViewPager is a layout widget in which each child view is a separate page (a separate tab) in the layout ALSO  known as tab layout.




for make tab layout us adapter class and view pager

each and every tab could be define different activity load or fragment also use in tab 



now we started with create a new activity 
  1.  Main Activity.xml
  2. Main Activity.java
  3. fst_fregment_layout.xml
  4. fst_fregment_layout.java
  5. snd_fragment_layout.xml
  6. snd_fragment_layout.java
  7. tab_adapter.java


1) Main Activity.xml



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    android:orientation="vertical"
    tools:context="com.example.store.tab_layout_app.MainActivity">




    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        >

    </android.support.design.widget.TabLayout>
    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>


2) MainActivity.java




package com.example.store.tab_layout_app;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TableLayout;

public class MainActivity extends AppCompatActivity {

    TabLayout tab_layout1 ;
    ViewPager view_pager ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tab_layout1 = (TabLayout)findViewById(R.id.tab_layout1);
        view_pager =(ViewPager)findViewById(R.id.view_pager);


        //for counter fregment
        //view_pager.setAdapter(new tab_adapter(MainActivity.this,getSupportFragmentManager()));
        //tab_layout1.setupWithViewPager(view_pager);


        tab_adapter tb = new tab_adapter (MainActivity.this,getSupportFragmentManager());
        tb.addFragment(new fst_fregment_layout(),"tab one");
        tb.addFragment(new snd_fragment_layout(),"tab two");
        tb.addFragment(new fst_fregment_layout(),"tab three");

        view_pager.setAdapter(tb);
        tab_layout1.setupWithViewPager(view_pager);

    }
}


3) fst_fregment_layout.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:gravity="center"
    android:orientation="vertical"
    android:descendantFocusability="blocksDescendants">

    <TextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />


</LinearLayout>


4)fst_fregment_layout.java



package com.example.store.tab_layout_app;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by store on 28-02-2018.
 */

public class fst_fregment_layout extends Fragment {

    String data ="";

    TextView tv3;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.fst_fregment_layout,container,false);
        tv3 = (TextView)rootView.findViewById(R.id.tv3);

        //data=getArguments().getString("name");
        tv3.setText("fst Fragment");

        return rootView;
    }
}




5)snd_fragment_layout.xml



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:gravity="center"
    android:orientation="vertical"
    android:descendantFocusability="blocksDescendants">

    <TextView
        android:id="@+id/tv3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="TextView" />


</LinearLayout>


6)snd_fragment_layout.java



package com.example.store.tab_layout_app;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by store on 28-02-2018.
 */

public class snd_fragment_layout extends Fragment {

    String data ="";

    TextView tv3;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.snd_fragment_layout,container,false);
        tv3 = (TextView)rootView.findViewById(R.id.tv3);

        //data=getArguments().getString("name");
        tv3.setText("snd Fragment");

        return rootView;
    }
}



7)tab_adapter.java

package com.example.store.tab_layout_app;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by store on 07-03-2018.
 */

public class tab_adapter extends FragmentPagerAdapter {

    private Context mContext;

    List<Fragment> fragment_list = new ArrayList<>();
    List<String> title_list = new ArrayList<>();

    public tab_adapter(Context context, FragmentManager fm) {
        super(fm);
        mContext = context;


    }
    public void  addFragment ( Fragment fragment , String title)
    {
        fragment_list.add(fragment);
        title_list.add(title);

    }


    @Override
    public Fragment getItem(int position) {

        return fragment_list.get(position);
        // This determines the fragment for each tab

       /* if (position == 0) {
            return new fst_fregment_layout();
        } else if (position == 1){
            return new snd_fragment_layout();
        } else {
            return new fst_fregment_layout();
        }*/
    }

    // This determines the number of tabs
    @Override
    public int getCount() {


        return fragment_list.size();
    }

    // This determines the title for each tab
    @Override
    public CharSequence getPageTitle(int position) {
        // Generate title based on item position

        return title_list.get(position);
        /* switch (position) {
            case 0:
                return "tab1";
            case 1:
                return "tab2";
            default:
                return null;
        }*/
    }

}


video preview for that activity:-





thank you

Wednesday, 28 February 2018

submit a sign up button alldata pass to next text view activity

submit a sign up button
all typed data pass to next 
text view activity ,
data pass through last activity   


sign_up  activity preview :-




make new activity pass following step -  

right clik on app bar in project structure .> new>activity>empty activity> name file text_view  



now we have

1) activity_sign_up.xml
2)sign_up.java
3)activity_text_view.xml
4)text_view.java




code :-

1) activity_sign_up.xml
 
     in that activity we are use  
   </LinearLayout>
    </ScrollView>
as shown preview on top


activity_sign_up.xml

<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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="com.example.store.n01.Sign_up">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <EditText
                android:id="@+id/edit_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="Name" />

            <EditText
                android:id="@+id/edt_mobileno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/edit_name"
                android:layout_alignRight="@+id/edit_name"
                android:layout_below="@+id/editText4"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="@string/mobile_no" />

            <EditText
                android:id="@+id/edt_passwardsu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText5"
                android:layout_alignRight="@+id/editText5"
                android:layout_below="@+id/editText5"
                android:ems="10"
                android:hint="@string/passward"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edt_mothername"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText7"
                android:layout_alignRight="@+id/editText7"
                android:layout_below="@+id/editText7"
                android:ems="10"
                android:hint="@string/mother_name"
                android:inputType="textPersonName" />

            <CheckBox
                android:id="@+id/checkBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/term_and_condition" />

            <Button
                android:id="@+id/btn_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:background="@drawable/btn_all"
                android:text="@string/sign_up"
                android:textAlignment="center"
                android:textSize="19sp"
                android:padding="10dp"
                android:gravity="center"/>


        </LinearLayout>
    </ScrollView>
</android.widget.RelativeLayout>


2)sign_up.java


package com.example.store.n01;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class Sign_up extends AppCompatActivity {
    EditText edit_name ,edt_mobileno ,edt_passwardsu ,edt_mothername;
    Button btn_signup ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_up);
        edit_name = (EditText)findViewById(R.id.edit_name);
        edt_mobileno = (EditText)findViewById(R.id.edt_mobileno);
        edt_passwardsu=(EditText)findViewById(R.id.edt_passwardsu);
        edt_mothername= (EditText)findViewById(R.id.edt_mothername);

        btn_signup =(Button)findViewById(R.id.btn_signup);

        btn_signup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String s1 = edit_name.getText().toString();
                String s2 =edt_mobileno.getText().toString();
                String s3 =edt_passwardsu.getText().toString();
                String s4 =edt_mothername.getText().toString();

                Intent i = new Intent(getApplicationContext(),text_view.class);
                i.putExtra("name",edit_name.getText().toString());
                i.putExtra("mobileno",edt_mobileno.getText().toString());
                i.putExtra("mothername",edt_mothername.getText().toString());
                i.putExtra("passwardsu",edt_passwardsu.getText().toString());

                startActivity(i);

               // Toast.makeText(Sign_up.this, s1 +"\n"+"\n"+s2 +"\n"+ s3+"\n"+s4, Toast.LENGTH_SHORT).show();

            }
        });

    }

}




3)activity_text_view.xml

activity preview :-

activity_text_view.xml

<?xml version="1.0" encoding="utf-8"?>
<android.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    android:orientation="vertical"
     >


    <TextView
        android:id="@+id/name_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/mobileno_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/passward_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />

    <TextView
        android:id="@+id/mothername_tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/textview" />
</android.widget.LinearLayout>


4)text_view.java

package com.example.store.n01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class text_view extends AppCompatActivity {

    TextView name_tv,mobileno_tv,passward_tv,mothername_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_view);

        name_tv = (TextView)findViewById(R.id.name_tv);
        mobileno_tv = (TextView)findViewById(R.id.mobileno_tv);
        passward_tv= (TextView)findViewById(R.id.passward_tv);
        mothername_tv= (TextView)findViewById(R.id.mothername_tv);

        name_tv.setText(getIntent().getStringExtra("name"));
        mobileno_tv.setText(getIntent().getStringExtra("mobileno"));
        passward_tv.setText(getIntent().getStringExtra("mothername"));
        mothername_tv.setText(getIntent().getStringExtra("passwardsu"));

    }
}


it was pass a data 1st activity to other activity run


sign up activity with scroll view XMLfile




we introduce sign_up layout xml file for


xml file sign_up


<?xml version="1.0"
 encoding="utf-8"?>
<android.widget.RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    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="com.example.store.n01.Sign_up">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <EditText
                android:id="@+id/edit_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="Name" />

            <EditText
                android:id="@+id/edt_mobileno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/edit_name"
                android:layout_alignRight="@+id/edit_name"
                android:layout_below="@+id/editText4"
                android:ems="10"
                android:inputType="textPersonName"
                android:hint="@string/mobile_no" />

            <EditText
                android:id="@+id/edt_passwardsu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText5"
                android:layout_alignRight="@+id/editText5"
                android:layout_below="@+id/editText5"
                android:ems="10"
                android:hint="@string/passward"
                android:inputType="textPersonName" />

            <EditText
                android:id="@+id/edt_mothername"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignEnd="@+id/editText7"
                android:layout_alignRight="@+id/editText7"
                android:layout_below="@+id/editText7"
                android:ems="10"
                android:hint="@string/mother_name"
                android:inputType="textPersonName" />

            <CheckBox
                android:id="@+id/checkBox"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/term_and_condition" />

            <Button
                android:id="@+id/btn_signup"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:background="@drawable/btn_all"
                android:text="@string/sign_up"
                android:textAlignment="center"
                android:textSize="19sp"
                android:padding="10dp"
                android:gravity="center"/>


        </LinearLayout>
    </ScrollView>
</android.widget.RelativeLayout>




PREVIEW OF XML FILE:-



login activity in xml file and java file for android

log in activity 



XML FILE ;




<?xml version="1.0" encoding="utf-8"?>
<android.widget.RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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"
    android:gravity="center"
    tools:context="com.example.store.n01.login_Activity">

    <EditText
        android:id="@+id/edt_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/text_box"
        android:hint="@string/email_or_username"
        android:inputType="textEmailAddress"
        android:padding="10dp"
        android:gravity="center"
        />

    <EditText
        android:id="@+id/edt_passward"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/edt_email"
        android:layout_alignStart="@+id/edt_email"
        android:layout_below="@+id/edt_email"
        android:layout_marginTop="25dp"
        android:background="@drawable/text_box"
        android:hint="@string/passward"
        android:inputType="textPassword"
        android:textAlignment="center"
        android:padding="10dp"/>

    <Button
        android:id="@+id/btn_login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/edt_passward"
        android:layout_alignStart="@+id/edt_passward"
        android:layout_below="@+id/edt_passward"
        android:layout_marginTop="43dp"
        android:background="@drawable/btn_all"
        android:textSize="18sp"
        android:text="@string/bt_login"
        android:gravity="center"
        android:padding="10dp"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignEnd="@+id/btn_login"
        android:layout_alignRight="@+id/btn_login"
        android:layout_below="@+id/btn_login"
        android:layout_marginEnd="21dp"
        android:layout_marginRight="21dp"
        android:layout_marginTop="16dp"
        android:text="@string/forget_passward" />
</android.widget.RelativeLayout>









PREVIEW OF XML FILE




java FILE :-

(in that file include all error massage for email
check out , password length ,intent press login button to sign_up activiety
toast make ,also)

package com.example.store.n01;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class login_Activity extends AppCompatActivity {

    EditText edt_email,edt_passward;
    Button btn_login;


    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login_);

        edt_email = (EditText)findViewById(R.id.edt_email);
        edt_passward= (EditText)findViewById(R.id.edt_passward);
        btn_login=(Button)findViewById(R.id.btn_login);

        btn_login.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {

                if(checkEmail(edt_email,"Enter Valid Email") && checkpassward(edt_passward,"Enter 6 cherecter passward")) {

                    Intent i = new Intent(getApplicationContext(),Sign_up.class);
                    startActivity(i);


                   // String s1 = edt_email.getText().toString();                    //String s2 = edt_passward.getText().toString();
                    //oast.makeText(login_Activity.this, s1, Toast.LENGTH_SHORT).show();
                   // Toast.makeText(login_Activity.this, s2, Toast.LENGTH_SHORT).show();                }

               
            }
        });

    }

    public boolean checkEmail(EditText edt,String msg)
    {

        if(edt.getText().toString() != null && edt.getText().toString() != ""                && edt.getText().toString().length() > 0 && Patterns.EMAIL_ADDRESS.matcher(edt.getText().toString()).matches())
        {
            return true;
        }
        else{
            edt.setError(msg);
            return false;
        }
    }
    public boolean checkpassward(EditText edt,String msg)
    {

        if(edt.getText().toString() != null && edt.getText().toString() != ""                && edt.getText().toString().length() >= 6 )
        {
            return true;
        }
        else{
            edt.setError(msg);
            return false;
        }
    }
}

Sunday, 25 February 2018

WHAT IS ANDROID ?

hello
,

we study about android in that blog post 's various day by day ,,


we started form the some introduction from android system

and than we are covered some TUTORIAL  most of cover EXAMPLES with code and other
covered to how anyone android application without , maximum pay frees or education .


WHAT IS ANDROID ? 

Android is a software stack ,of mobile , and many of the smart phone us OS is android 
that includes OS , middle ware, and most we us APPLICATIONS  .


now most important tool is develop to android is SDK ,

it is provides APK to develop application on android plate form 
using a JAVA .






1) APPLICATION

            like also PHONE , BROWSER,GALLERY ,

2) APPLICATION FAME WORK 
          
           LIKE ,,, TELEPHONE MANAGER,,, LOCATION MANAGER (google location and other app us) , NOTIFICATION MANAGER ( us in all application generally notify to phone in main screen , like WHAT'S APP massage notification , and many other one,   )


3) LIBRARIES 
also include SURFACE MANAGER , FREE TYPE now a days WEB KIT , more


4) ANDROID RUN TIME 

       1) Core libraries 
       2) Dalvik virtual Machine 

5) LINUX KERNEL

      ti is section of driver like some us full to run hard ware and cancers , tough pad , camera
in that include driver some example   
  • Display Driver
  • Camera Driver
  • Flash Memory Driver
  • AudioDriver
  • WI-FI Driver
  • Power Management







we meet to next blog for more information and start programming android and some set -up studio 

thank you

  

B Remi Calculator

Loan Calculator Loan Calculator Loan Amount PF Cross Sell (LI % GI) No Yes EMI CARD No Ye...