I am just replacing fragment to show other fragment in my application.its working fine its showing fragment2,But when try to remove it removes only my layouts not a fragment.How to remove my fragment?
P.S :When I click on home button then my fragment removed.
here is my code snippet
fragment2= new MyFragment(context, ls);
Bundle intent = new Bundle();
intent.putSerializable("lookup_response", prepareData(5));
lookupfragment.setArguments(intent);
FragmentTransaction ft= ((MyActivity)context).getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment2, "FrahmentTag");
ft.addToBackStack(null);
ft.commit();
to remove my fragment
FragmentTransaction ft = ((DashBoardActivity)context).getSupportFragmentManager().beginTransaction();
ft.remove(myfragment);
ft.commit();
can anyone help me what am doing wrong in this?thanks
Hi friends i solve this problem by this lines
ft.add(R.id.container, fragment2, "FrahmentTag");
ft.addToBackStack(null);
ft.commit();
Instead of ft.replace(R.id.container, fragment2, "FrahmentTag");
and when removing fragment used this
getFragmentManager().popBackStack();
Related
I have a activity which is hosting 3 fragments. A,B,C. For the hosting activity and Fragment A, it should show the options menu, so I am inflating it in fragment A.
Now For fragment B and C I just want to display the action bar(having title and back arrow), and disable the complete options menu dropdown(the 3 dots in the right corner).
I tried using setHasMenuOptions(false) in fragments B and C but its not working.
Is there any option to hide the three dots with dropdown in other two fragments.
My activity has the following code to perform the back navigation. Everything is working fine accept hiding the complete menu in the two fragments B and C.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
super.onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Override onPrepareOptionsMenu in yor fragment class and do menu.clear();
Also do setHasMenuOptions(true);
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.clear();
}
Wondering if someone might help with another pair of eyes - as I am trying to work out why some of my Famo.us 'Views' are being displayed despite having an opacity StateModifier set to '0'.
Here is my code - My apologies for it not being standard - I have "Panels" instead of "Views" and a few other things..but happy to expand on the code if needed.
function _buildSidePanel() {
this._sidePanel = _createPanel.call(this);
this._sidePanel.setOptions(this.constructor.DEFAULT_OPTIONS.sideMenu);
this._sidePanel.position = this.cm(this.constructor.DEFAULT_OPTIONS.sideMenu.position);
this._container.add(this._sidePanel.position).add(this._sidePanel);
this._menuHolder = _createPanel.call(this); //My version of a View
this._menuHolder.setOptions(this.constructor.DEFAULT_OPTIONS.sideMenu.menuHolder);
// Create StateModifiers
this._menuHolder.position = this.cm({ align: [.5,.6], origin: [.5,.6], proportions: [.9,.8] });
this._menuHolder.fadeState = this.cm({ opacity: 0 });
this._menuHolder.sizeState = this.cm();
this._menuHolder.mC = new ModifierChain();
this._menuHolder.mC.addModifier(this._menuHolder.fadeState);
this._menuHolder.mC.addModifier(this._menuHolder.sizeState);
this._menuHolder.mC.addModifier(this._menuHolder.position);
/* Tried splitting it to just modifiers but getting the same thing
this._sidePanel._container.add(this._menuHolder.fadeState)
.add(this._menuHolder.sizeState)
.add(this._menuHolder.position)
.add(this._menuHolder);
*/
this._sidePanel._container.add(this._menuHolder.mC).add(this._menuHolder);
// this._menuHolder.fadeState.setOpacity(1,this.constructor.DEFAULT_OPTIONS.sideMenu.menuHolder.transition.in);
}
I have created a ModifierChain and added among other things an Opacity State of 0. When I add this and then add the modifier and 'View' to the container it displays the View even though the View has a StateModifier of '0' so should not be displayed.
The 'fadeState.setOpacity' command is meant to transition the fadeState to display the View but it is commented out, so the View should not be displayed.
I have this working in other areas so know the approach works. I am also (hopefully) not using the same variable names, so not using a StateModifier more than once. But still stuck as to why this is being displayed.
Any help or thoughts would be gratefully appreciated.
Thanks.
I have 2 Scenes, "one scene is just an empty scene with a button" and "another scene has one TableView". I would like to switch back and forth, my code that is using to switch the scenes is
shown below:
scence1 to scene2
auto scene2 = Scene2::createScene();
Director::getInstance()->replaceScene(scene2);
scene2 to scene1
auto scene1 = Scene1::createScene();
Director::getInstance()->replaceScene(scene1);
I suspect that TableViewCell make the program crashes.
Here is my code to create TableView in scene2:
Size tvSize = Size(640.0, 640.0);
_tableview = TableView::create(this, tvSize);
_tableview->retain();
_tableview->setDirection(cocos2d::extension::ScrollView::Direction::VERTICAL);
_tableview->setPosition(Point(0.0 , 0.0 + ((640.0 - tvSize.height)/ 2.0)));
_tableview->setDataSource(this);
Remarkable: cocos2d-x v3.0 beta
UPDTE:
Thank you everyone for helping me, right now I be able to fix it,
The caused of the error is I add this line:
_eventDispatcher->addEventListenerWithFixedPriority(listener, 1);
and forgot to add this line when we finish using _eventDispatcher:
_eventDispatcher->removeEventListener(_touchListener);
I have a custom product list page and i´m using the following code to show the pagenumbering and filters:
$pager = $this->getLayout()->createBlock('page/html_pager');
echo $this->getLayout()->createBlock('catalog/product_list_toolbar')->setChild('product_list_toolbar_pager', $pager)->setCollection($products)->toHtml();
If i'm changing the mode from grid to list view nothing happens.
How can i get the active mode (grid or list).
Magento normaly uses $this->getMode() but this one doesnt work.
I have fixed it with the following code:
$mode = $this->getLayout()->createBlock('catalog/product_list_toolbar')->setChild('product_list_toolbar_pager', $pager)->getCurrentMode();
Another solution,
if(Mage::getSingleton('catalog/session')->getDisplayMode())
{
$productListMode=Mage::getSingleton('catalog/session')->getDisplayMode();
}
After a lot of looking here and there I am posting this problem that I am facing on SO. Basically I have an Action bar with a tabbed layout. Below is a snapshot of how it looks now :
And here is the code chunk that sets the tabs :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_example);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
setContentView(R.layout.landing_page);
ViewPager viewPager = (ViewPager) findViewById(R.LandingPage.pager);
final ActionBar bar = getSupportActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mTabsAdapter = new LandingPageTabsAdapter(this, viewPager);
mTabsAdapter.addTab(bar.newTab().setText("Search"), Search.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Categories"),Categories.class, null);
mTabsAdapter.addTab(bar.newTab().setText("Bookmarks"), Bookmarks.class,null);
}
I want to add a straight line just below the tab highlighter, which is of the same color as the tab highlighter. Something like the line in Google Playstore (green line circled in red):
Currently I am styling the Actionbar using the Android Asset Studio's ActionBar Style Generator. My only reason to put the line there is to get a clean look.
Can someone suggest / advice on how I can solve this ? Thanks for stopping by and lending in your thoughts.
Instead of adding a line below your actionbar try adding a line above your viewpager in your layout. Also the play store isn't using tabs they are using the PageTitleStrip