Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:58:43+00:00 2026-06-05T02:58:43+00:00

This is my code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.email_list_main); emailResults =

  • 0

This is my code

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

        emailResults = new ArrayList<GetEmailFromDatabase>();

        //int[] colors = {0,0xFFFF0000,0};
        //getListView().setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
        //getListView().setDividerHeight(2);

        emailListFeedAdapter = new EmailListFeedAdapter(this, R.layout.email_listview_row, emailResults);
        setListAdapter(this.emailListFeedAdapter);

        getResults();
        if(emailResults != null && emailResults.size() > -1){
            emailListFeedAdapter.notifyDataSetChanged();
        for(int i=0;i< emailResults.size();i++){
            try {

Here I getting email Sent date

                emailListFeedAdapter.add( emailResults.get(i));

                datetime_text1 = emailResults.get(i).getDate();
                formatter1 = new SimpleDateFormat();
                formatter1 = DateFormat.getDateInstance((DateFormat.MEDIUM));

                Calendar currentDate1 = Calendar.getInstance();

                Item_Date1 = formatter1.parse(datetime_text1);
                current_Date1 = formatter1.format(currentDate1.getTime());
                current_System_Date1 = formatter1.parse(current_Date1);

                currentDate1.add(Calendar.DATE, -1);

                yesterdaydate = formatter1.format(currentDate1.getTime());
                yeaterday_Date = formatter1.parse(yesterdaydate);

                currentDate1.add(Calendar.DATE, -2);

                threeDaysback = formatter1.format(currentDate1.getTime());
                Three_Days_Back = formatter1.parse(threeDaysback);

Here I am comparing current date with list view item date, and here is my problem, dates are matching but it is not adding separator I tried in so many ways but nothing worked the code for separator is bellow.

                if(Item_Date.compareTo(current_System_Date)==0){
                    if(index1){

                       emailListFeedAdapter.addSeparatorItem("SEPARATOR");
                       //i--;
                       index1=false;
                    }


                }
                else if(yeaterday_Date.compareTo(Item_Date1)==0){
                    if(index2){
                       emailListFeedAdapter.addSeparatorItem("SEPARATOR");
                       //i--;
                       index2 = false;
                    }

                }
                else if(Item_Date1.compareTo(Three_Days_Back)==0){
                    if(index3){
                       emailListFeedAdapter.addSeparatorItem("SEPARATOR");
                       //i--;
                       index3 = false;
                    }

                }
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
        }
     }
}

In EmailListFeedAdapter

     private TreeSet<Integer> mSeparatorsSet = new TreeSet<Integer>();
     public void addSeparatorItem(final String item) {
         //itemss.add(emailResults.get(0));
            // save separator position
            mSeparatorsSet.add(itemss.size() - 1);
            notifyDataSetChanged();
        }
    @Override
    public int getItemViewType(int position) {
         return mSeparatorsSet.contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
       }
         holder = new ViewHolder();
        switch (type) {

            case TYPE_ITEM:
                 emailView= inflater.inflate(R.layout.email_listview_row, null);

                break;
            case TYPE_SEPARATOR:
                 emailView= inflater.inflate(R.layout.item2, null);
                 holder.textView = (TextView)emailView.findViewById(R.id.textSeparator);
                 emailView.setTag(holder);
                 holder.textView.setText("SEPARATOR");
                break;
        }

Here is ViewHolder class

       public static class ViewHolder {
        public TextView textView;
    }

if anybody knows then please tell me where I am doing wrong.

Thanx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:58:44+00:00Added an answer on June 5, 2026 at 2:58 am

    I solved this problem take another xml layout every thing should be same in this xml layout but add another view extra in this layout example Text view and save it with different name, now when ever u want to add separator u have to inflate this layout instead of the regular layout u are inflating. remember that when u inflate this layout it is taking place of the item in your adapter, so your skipping that item you need to go back to that position in array and display that data in listview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code: public class MenuTabActivity extends TabActivity implements OnTabChangeListener{ @Override protected void onCreate(Bundle
I have onPause in activity and works great. This is code @Override protected void
i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource =
In this code (from the WCF REST starterkit - preview2): protected override SampleItem OnAddItem(SampleItem
I have this code: @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0, 0,
In facebook tutorials I see this sample code: @Override public void onActivityResult(int requestCode, int
In my onCreate, the following code executes: dialog = new ProgressDialog(this); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); dialog.setMessage(Welcome!
So, why does this code: package org.popoffka.apicross; import android.app.Activity; import android.os.Bundle; import android.widget.Button; public
onRestoreInstanceState(Bundle savedInstanceState) is not geting called, I am pasting my code below. Actually I
This code is from Apple's WWDC 2011 Session 318 - iOS Performance in Depth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.