Posts

how to create custom listview in android

1. Create a Activity MainActivity :- :- in XML file <?xml version="1.0" encoding="utf-8"?> <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=".MainActivity"     android:background="@drawable/side_nav_bar">     <ListView         android:id="@+id/study_mode_list_item"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_marginLeft="8dp"         android:divider="#8A46A005"         android:dividerHeight="1.5dp"         android:footerDividersEnabled="true"         android:layout_marginRight=&

How to Work with Recycler View in android

1. Open build.gradle and add recycler view dependency :- implementation 'com.android.support:recyclerview-v7:28.0.0' Created A activity like MainAcvitiy :- :- XML File  <?xml version="1.0" encoding="utf-8"?> <androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="vertical" android:id="@+id/recyclerView"> </androidx.recyclerview.widget.RecyclerView> :- JAVA File   package com.example.demorecycler; import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; public class MainActivity extends AppCompatActivity {     @Override     protected

How to Create Spalace Layout

Now create a activity and add following code : 1. XML File <?xml version="1.0" encoding="utf-8"?> <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=".SpalaceAct"     android:background="@drawable/side_nav_bar">     <ImageView         android:id="@+id/imageView2"         android:layout_width="match_parent"         android:layout_height="186dp"         android:layout_marginTop="150dp"         app:srcCompat="@mipmap/logo_image" />     <TextView         android:id="@+id/textView2"         android:layout_width="match_parent"         android:layout_height="

Android Custom Drawable Layout

package com.example.demodrawernaviga2; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import android.view.View; import androidx.core.view.GravityCompat; import androidx.appcompat.app.ActionBarDrawerToggle; import android.view.MenuItem; import com.google.android.material.navigation.NavigationView; import androidx.drawerlayout.widget.DrawerLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.view.Menu; import android.widget.Toast; public class MainActivity extends AppCompatActivity         implements NavigationView.OnNavigationItemSelectedListener {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         Toolbar toolba

BaseAdapter Tutorial With Example In Android Studio

Now -> Activity->  BassAdd2  and add following code. Here we will create Gridview inside LinearLayout :- 1.  XMl file:- <?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"     tools:context=".BassAdd2"     android:orientation="vertical">     <GridView         android:id="@+id/simpleGridView1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:numColumns="3"         /> </LinearLayout> 2. JAVA file :- package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; import android.cont

How to Create Fragment, Example In Android Studio

Open res -> Activity FrameMainActivity-> and add following code: Layout file :- <? xml version ="1.0" encoding ="utf-8" ?> < RelativeLayout android :id ="@+id/main_layout" 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" > < com.google.android.material.tabs.TabLayout android :id ="@+id/tab_layout" android :layout_width ="match_parent" android :layout_height ="wrap_content" android :layout_below ="@+id/toolbar" android :background ="?attr/colorPrimary" android :minHeight ="?attr/actionBarSize" android :theme ="@style/ThemeOverlay.AppCompat.Dark.Ac