question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single event title getting displayed multiple times

See original GitHub issue

I am displaying the weekview in a DialogFragment. There is just one event added to it but the problem now is that the same event title is getting displayed multiple times within the event. As I see in the screenshots I believe just one title should be displayed. My Code:

public class WeekviewFragment extends DialogFragment implements WeekView.MonthChangeListener, WeekView.EventClickListener {
private WeekView mWeekView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.weekview, container, false);
    mWeekView = (WeekView) view.findViewById(R.id.weekView);
    mWeekView.setMonthChangeListener(this);
    mWeekView.setOnEventClickListener(this);
    return view;
}

@Override
public List<WeekViewEvent> onMonthChange(int i, int i2) {
    // Populate the week view with some events.
    List<WeekViewEvent> events = new ArrayList<>(1);

    Calendar startTime = Calendar.getInstance();
    startTime.set(Calendar.HOUR_OF_DAY, 3);
    startTime.set(Calendar.MINUTE, 0);
    startTime.set(Calendar.MONTH, 1);
    startTime.set(Calendar.YEAR, 2015);
    Calendar endTime = (Calendar) startTime.clone();
    endTime.add(Calendar.HOUR_OF_DAY, 4);
    endTime.set(Calendar.MONTH, 1);
    WeekViewEvent event = new WeekViewEvent(1, "This is title", startTime, endTime);
    event.setColor(getResources().getColor(R.color.accent_color_dark));
    events.add(event);
    return events;
}

}

Layout code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MyActivity"
            android:background="#fff">

<com.alamkanak.weekview.WeekView
    android:id="@+id/weekView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:eventTextColor="@android:color/white"
    app:textSize="12sp"
    app:hourHeight="60dp"
    app:headerColumnPadding="8dp"
    app:headerColumnTextColor="#8f000000"
    app:headerRowPadding="12dp"
    app:columnGap="8dp"
    app:noOfVisibleDays="3"
    app:headerRowBackgroundColor="#ffefefef"
    app:dayBackgroundColor="#05000000"
    app:todayBackgroundColor="#1848adff"
    app:headerColumnBackground="#ffffffff"/>
</RelativeLayout>

image

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
entropitorcommented, Jun 15, 2015

The onMonthChange is called three times: One time for this month and then one time for the previous and next month (for smooth scrolling). Because you’re providing the events three times, they are rendered three times.

(you should only return the events that fall within the month that is requested, based on the arguments passed in onMonthChange)

0reactions
wysohncommented, Mar 24, 2019

@JillevdW Have a look into my example, then you will figure it out easily.

The startDate and endDate is Calendar, and look carefully at how I got the month of the Calender instance.

Hint:

if(today.get(Calendar.MONTH) != month)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Events with multiple dates/times as a single event.
I know recurring events are a thing but is there a way to display them as only ONE entry in the event list?...
Read more >
Title displaying multiple times - WordPress Stack Exchange
I'm facing a problem where my title is being displayed multiple times. Using the following code the page title 'News' is displayed 10...
Read more >
Display more Text in fullcalendar - Stack Overflow
Show activity on this post. I am looking for a solution to display more information in event. For example in the DayView you...
Read more >
Single Event Shortcode - Knowledgebase
Displays the venue name as link to the single-venue page. ... ⚠️Please Note: Events support having multiple organizers. With this in mind, the ......
Read more >
If you have duplicate events on your iCloud Calendar
Contact Apple Support. Need more help? Save time by starting your support request online and we'll connect you to an expert. Get started ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found