I tried to set up a onClickListener inside my fragment.
public class HomeFragment extends Fragment implements View.OnClickListener {
Button btn_eventList;
public HomeFragment() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
btn_eventList = (Button) view.findViewById(R.id.buttonEventList);
btn_eventList.setOnClickListener(this);
return view;
}
#Override
public void onClick(View v) {
btn_eventList.setText("TEST");
Toast.makeText(getActivity(), "TEST" , Toast.LENGTH_SHORT).show();
}
}
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/nvd"
android:layout_height="match_parent"
android:layout_width="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="test"
android:textAppearance="#style/TextAppearance.AppCompat.Display1"
/>
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="1dp"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="45dp"
android:orientation="horizontal">
<Button
android:id="#+id/buttonEventList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/button9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
<Button
android:id="#+id/button7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/lst_nav_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
>
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.DrawerLayout>
Does anyone know why the onClick method never gets called when I hit my button? Did I miss anything?
EDIT
Since Sevin made me notice I was not giving you a solution but an alternative way for reaching your goal, I'm editing this.
First: your code must work
The code you posted is correct
Now, do some checks:
Check if in debug mode the button is not null (should have throwed exception)
Check if in debug mode you are reaching the onClick, even if the text doesn't change and even if the toast doesn't show up.
Check if you are showing the fragment properly. Here is the official documentation about how to create a fragment.
Check if the fragment is clickable and if it has anything over it (simply, the button once clicked shows the classic "click" animation?)
Check in the xaml code if the id you used is assigned to the correct button.
And finally do some the following operations:
Clean your project
Rebuild your project
Check if in both xaml and java code you have any alert (in basic configurations, yellow mark over the line)
Uninstall the app and re-install it (pretty much the same, but since we don't know your project, it can still help)
After those, let us know
Possible solution:
You have a recycleview which is on top of the button. you have this view set with match parent both height and width inside a relativelayout, it means that this view will cover the button.
Remove this empty recycleview and the code will work
EDIT
after posting your layout I can conclude with total certainty that your REcyclerView is taking all the space of your layout thus taking all the touch inputs from whats behind.
Solutions:
You can either delete the recycler view or re-arrange it and add it to last RelativeLayout and use layout_below and placing it below the a LinearLayout
The problem is that you didn't implement this method right. onClick() method doesn't know, what view concretely has been clicked. Change your onClick() method to the following form:
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.your_button_id:
btn_eventList.setText("TEST");
Toast.makeText(getActivity(), "TEST" , Toast.LENGTH_SHORT).show();
break;
}
}
Related
I have activity which has two fragments. Activity contains TabLayout only (2tabs) where these two fragments fill up the tabs body.
Everything works when I first start the app, all colors are correctly loaded from colors.xml. When I press backpress button (tried in 2 emulators and also real device, API from 23 to 28), and I reopen the app, color (#222222) of the active tab and also color (#222222) of other elements everywhere in the fragment changes to the primary color which is colorAccent: #color/green in my case. And this green color is loaded normally. Other colors in the app do NOT change at all, they stay as they are defined.
I spent 6 hours debugging this problem, I have no clue, why other colors stay as they should.
I have experimented and added a new activity which starts when I click on button in the fragment and I set this activity background color to the same #222222 which defined in my colors.xml as <color name="darkg">#222222</color>.
The background in this activity is always green, even after I start the app normally (not resuming) while the active tab button is darkg color.
This is how I start my framgent from their parent activity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inside);
fm = getSupportFragmentManager();
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(fm);
// Set up the ViewPager with the sections adapter.
mViewPager = findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = findViewById(R.id.tabs);
mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
}
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
switch (position){
case 0:
return watchList;
case 1:
return exbook;
default:
return null;
}
}`
I have tried to remove some dependencies which I thought can cause this problem, I have cleaned project enormous number of times, I have invalidated caches and restarted android studio, nothing ever helped.
My app is supported from Android 5.0, I tried to test it on emulator with API 23, tab color doesn't change there, only other elements in the fragment. On the other hand, I tested on emulator with API 28 and also real device API 28, and tab button changes to green also with other elements in fragment + that activity is always green.
I should also mention, that in my fragment, I have recyclerview and I have alternate rows background color set like this (it is set in Adapter.class, and this color works always, never changes to green:
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
//holder.textViewPos.setText("#" + (position + 1));
holder.swipeLayout.setOffset(itemsOffset[position]);
//((RecyclerView.LayoutParams) holder.itemView.getLayoutParams()).height = 300;
if(position %2 == 1)
{
holder.itemView.setBackgroundColor(Color.parseColor("#222222"));
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFFFF"));
}
else
{
holder.itemView.setBackgroundColor(Color.parseColor("#2B2B2B"));
// holder.imageView.setBackgroundColor(Color.parseColor("#FFFAF8FD"));
}
}
XML file for activity, where I have TabLayout:
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".InsideActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:background="#fff">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="52dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="15dp"
android:layout_weight="1"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/logo" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="65dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:tabBackground="#drawable/tab_color_selector"
app:tabIndicator="#color/darkg">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Watchlist" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exbook" />
</com.google.android.material.tabs.TabLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.me.appka.NonSwipeableViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</com.me.appka.NonSwipeableViewPager>
Fragment XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="#+id/addToWatchlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/darkg"
android:fontFamily="sans-serif"
android:gravity="center_vertical"
android:includeFontPadding="true"
android:onClick="onClickAddNewPerson"
android:text="ADD NEW"
android:textAlignment="center"
android:textColor="#color/details_text"
android:textSize="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_below="#id/addToWatchlist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Activity XML which is started in Fragment when I click on the button addToWatchlist:
<androidx.constraintlayout.widget.ConstraintLayout
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=".AddToWatchlistActivity"
android:background="#color/darkg">
<TextView
android:id="#+id/watchlistTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Add new person to you Watchlist"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="18dp"
app:layout_constraintBottom_toTopOf="#+id/profile_image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
UPDATE:
I have checked LogCat in more detail and found some lines saying Choreographer(abc): Skipped xx frames! The application may be doing too much work on its main thread. So I went through my code again, I do not have anything that could cause too much work, but I have also checked resources, especially drawables and reduced 2 files (png) to smaller size, from 1MB to about 80KBand that warnings are gone and the color changing behaviour has also changed a little.
When I pressed back button before, and got back into app, dark gray tab + button turned green. Now, when I get back into app right after I press back button, Tab color stays gray, only button in fragment changes to green. When I go out of app and get back again over and over fast enough, it stays that way, but if I wait like 2 seconds and then get back into app, also Tab color changes from gray to green.
This is super odd, I have no clue what is wrong.
Remove this In Your Tab Layout ** app:tabIndicator="#color/yourColor"**
I have solved this problem myself.
I went through TabLayout in XML again, step by step and now it works. I did not analyze what I did different, but this is working XML TabLayout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
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=".InsideActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent">
<ImageView
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="74dp"
android:contentDescription="Title"
android:padding="8dp"
app:srcCompat="#drawable/logo" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="#color/darkg"
app:tabSelectedTextColor="#android:color/white"
app:tabTextColor="#android:color/black">
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Watchlist" />
<com.google.android.material.tabs.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ExBook" />
</com.google.android.material.tabs.TabLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.fre.book.NonSwipeableViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I have the following CardView:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="expandCollapse">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="18sp"
android:text="Heading Goes Here" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="#drawable/ic_action_down" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Description Goes Here"
android:visibility="gone" />
</LinearLayout>
</android.support.v7.widget.CardView>
Now, there are many of these cardviews, so I want to make my expandCollapse function work with all of them.
So basically, when the CardView is clicked, I want it to show or hide the Description Goes Here TextView depending on it's current visibility. It will either be GONE or VISIBLE. I also want it to change the ImageView arrow based on the current visibility.
Basically I just want this card to expand/collapse the textview inside of it. I know how do to this, but I don't know how to select the child TextView dynamically inside of my function.
How exactly do I select this TextView when the card is clicked, considering I will not be specifying an id for it, since I want this to work with many different CardView having the exact same layout?
I figured it out.
I simply added a tag to the TextView with android:tag="desc"
Then I used TextView textView = view.findViewWithTag("desc"); in my onClick function.
Here is my layout file code
Everything is working fine but Button in not clickable.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/maps"
android:gravity="center_horizontal"
android:orientation="vertical">
<include layout="#layout/custom_actionbar" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="30dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/pf_color"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="TRACK"
android:textSize="20dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Please help related this problem. I am thankful to you.
I am not able to sort out what is the actual problem. I tried android:clickable="true" but still same problem
Thanks in advance.
Try putting this line into your button in the XML:
android:onClick="myClickFunction"
So it would be:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/pf_color"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:text="TRACK"
android:textSize="20dp"
android:onClick="myClickFunction" />
And then put this in your activity:
public void myClickFunction(View v) {
// do stuff when clicked
}
dont forget to set onCLickListener
does ur main class implements onClickListener if so do:
public void onClick(View v) {
switch (v.getId()) {
case: R.id.YOURBUTTON:
//do ur stuff
break;
default:
//todo when the screen is touched
break;
}
}
I couldnt find your buttons ID btw thats why I called it YOURBUTTON
Do you use latest support library, com.android.support:support-v4:24.0.0? I think it's a bug because i have the same problem..
I am trying to achieve the following hierarchy:
GridView -> Every item is a view (let's call it 'container') that contains a background, ImageView and CheckBox.
If the user clicks on the container, it doesn't matter where, whether over the checkbox, image, or the background, the CheckBox should change it checked state.
Right now I have the following layout for it:
<!-- main layout -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<Button android:id="#+id/selectBtn"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Select" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:minWidth="200dp" />
<GridView android:id="#+id/imageGridView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:numColumns="auto_fit" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:columnWidth="90dp"
android:stretchMode="columnWidth" android:gravity="center"
android:layout_above="#id/selectBtn" />
</RelativeLayout>
<!-- gallery item layout - every grid item is inflated from this -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView
android:id="#+id/thumbImage"
android:layout_width="110dp"
android:layout_height="110dp"
android:background="#999999"
android:layout_centerInParent="true"
android:contentDescription="image thumb"/>
<CheckBox
android:id="#+id/itemCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
After this I want to be able to retrieve the checked containers.
I don't really know how to create this layout. Even tho my layout appears alright now, there is no 'container' that would react to click listener. I can only make the checkbox react to click, which is of course not very user-friendly. So how could I add a wrapper container around these views that would serve for clicking? Thanks a lot!
Ah, never mind... As RelativeLayout extends View and ViewGroup, I can just use something like:
RelativeLayout container = (RelativeLayout) holder.imageview.getParent();
container.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Log.d("test", "clicked");
RelativeLayout cont = (RelativeLayout) v;
CheckBox cb = (CheckBox) cont.getChildAt(1);
if(cb.isChecked()) cb.setChecked(false);
else cb.setChecked(true);
}
});
You also could use setOnItemClickListener() method of GridView to set the click listener for the item (image + checkbox). And inside your listener you can change the checked state of checkbox.
Good luck!
My web view displayed well without any problem. However, after I apply "Selected Text" function, the web view is then shown on only a half of the screen (see the image below).
Here is my code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.content);
Intent i = this.getIntent();
final int wordId = i.getIntExtra("id", -1);
mCurrentWord = i.getStringExtra("word");
mSelectedDB = i.getStringExtra("db");
mContentStyle = i.getStringExtra("style");
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
loadHistoryFromPreferences();
loadFavouriteFromPreferences();
wvContent = (WebView) findViewById(R.id.wvContent);
initWebview();
String content = getContentById(wordId);
showContent(content);
//This is the beginning of what I added
webkit=new Webkit(this);
wvContent.addView(webkit);
WebkitSelectedText webkitSelectedText=new WebkitSelectedText(getApplicationContext(), webkit);
webkitSelectedText.init();
wvContent.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
finish();
}
});
//This is the end of what I added
I have no idea what I have done wrongly. Except this display problem, all other functions including new added one Selected text work just fine.
I hope you guys could realise the problem and do me a favour to fix it. Thank you very much.
EDITED
Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="bottom|fill_vertical"
>
<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:layout_weight="1"
>
<WebView
android:id="#+id/wvContent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<ImageButton
android:id="#+id/btnHome"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/home"
android:layout_weight="0.25"
/>
<ImageButton
android:id="#+id/btnPronounce"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/pronounce"
android:layout_weight="0.25"
/>
<ImageButton
android:id="#+id/btnShowHistory"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/history"
android:layout_weight="0.25"
/>
<ImageButton
android:id="#+id/btnAddFavourite"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="#drawable/add_favourite"
android:layout_weight="0.25"
/>
</LinearLayout>
The problem may be with the layout.
In content.xml in res/layout, make sure you set the properties of webview's android:layout_height to fill_parent.
That should fix. It not, paste the contents of the layout too. And we can help
I'm not sure if this may help guys with similar problem or not, but in the end I solve my problem by changing:
wvContent.addView(webkit);
to
wvContent.addView(webkit,0,0);
Not really a solution but a workaround, perhaps.
I was getting the same problem and think I fixed it with the following code in the WebViewClient:
webView.setVisibility(View.VISIBLE);
My issue was that it only displayed half screen on first load, as soon as I clicked on a menu or changed the orientation of the device, the view was re-drawn at full screen. setting it to Visible seemed to trigger a re-draw that fixe