Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

 2 Answer(s)

  • Create a custom adapter for list view, inside getview method do the following

    • Create an xml file

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout&#95;width="match&#95;parent"
                android:layout&#95;height="match&#95;parent">
      
      
      <TextView
          android:id="@+id/list&#95;header"
          android:layout&#95;width="wrap&#95;content"
          android:layout&#95;height="wrap&#95;content"
          android:text="I am new header"/>
      
      
      <TextView
          android:id="@+id/item"
          android:layout&#95;width="match&#95;parent"
                android:layout&#95;height="wrap&#95;content"
                android:gravity="center"
          android:text="i am list item"/> 
       </LinearLayout>
      

      // in above code please replace _ with _ (underscore) Inside get view method check the object like it belongs to which model and and then hide or show the header.

      if(object belongs to the previous model object){
           list_header.setVisiblity(View.GONE);
        }else{
             list_header.setVisiblity(View.VISIBLE);
             list_header.setText(MODAL Class name);
        }
    

    Modify the code as your requirement but logic will be same.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: