qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
There were confrontation and violence (small skirmishes) between the 2 sides; but it was minimal (other than the car attack) This is the only link I could find about arrests, it does not say if there were from one side or the other. <http://www.cbsnews.com/news/white-nationalists-rally-charlottesville-live-updates/> > > **Virginia State Police said Saturday night that three people had been arrested in connection to the rally**. Troy Dunigan, 21, of Chattanooga, Tenn., was charged with disorderly conduct; Jacob L. Smith, 21, of Louisa, Va., was charged with misdemeanor assault and battery; and James M. O'Brien, 44, of Gainesville, Fla., was charged with carrying a concealed weapon, Virginia State Police said. > > >
It's easy to find incidences of "right" wing violence in the left wing media. If you want to find left wing violence, you have to look in the right wing media. E.g. [Breitbart](http://www.breitbart.com/big-government/2017/08/12/female-reporter-for-the-hill-allegedly-punched-by-antifa-protester-in-charlottesville/) reports that a female reporter for The Hill was punched in the face: > > A female reporter for the Hill was allegedly punched by an “Antifa” protester in the wake of a deadly car attack in Charlottesville, Virginia Saturday as she tried to film the ensuing chaos. > > > And quotes her twitter feed: > > > > > > Turns out the guy who punched me in the face for recording after the incident already had a warrant out for his arrest. So he's being held. > > > > > > > > > — Taylor Lorenz (@TaylorLorenz) [August 12, 2017](https://twitter.com/TaylorLorenz/status/896450940995346432) > > > That was purportedly posted from the police station where she was waiting to make her report. I have yet to hear anyone in the government denounce that bit of violence. Other reports agree that counter protesters (left wing) were deliberately inciting the protesters ("right" wing). E.g. [The Times of Israel](http://www.timesofisrael.com/counter-protesters-face-off-with-white-nationalists-in-virginia-ahead-of-far-right-rally/) reported: > > Earlier, the counter-demonstrators shouted “From the Midwest to the South, punch a Nazi in the mouth,” and “Nazi scum” at far-right attendees gathering at Emancipation Park in the city where the rally will be held. > > > It's worth noting that while all Nazis are white nationalists, not all white nationalists are Nazis. So when you see people refer to the protesters as Nazis, they are using a derogatory slur. The protest was about a statue of Robert E. Lee being scheduled for removal. Lee was a Confederate general during the Civil War. He died decades before the Nazis came to be. While remembered as allying with racists during the Civil War, he was not a Nazi. He did not advocate genocide against Jews, blacks, or anyone. Some people who support him now may be Nazis.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
Bottom Line Up Front ==================== Yes, there was violence perpetrated by both AntiFa and the White Supremacists. [Ben Shapiro's](https://www.youtube.com/watch?v=67zCG-KPWfQ) show the day after properly highlights the violence on each side (specific parts showing violence will be referenced below). That there was violence on one side does not dismiss or excuse the violence on the other side. That there was violence on both sides does not excuse the domestic terrorism incident perpetrated via vehicular murder. Making it Abundantly Clear ========================== Many are highlighting a difference in the **magnitude** of the violence that was perpetrated by both sides, as if to insinuate that because the member of one side committed vehicular murder, the severity of the violence by the other side is lessened. This establishes a logical fallacy. To start, consider the course of events without the pinnacle of violence: each side had actors that engaged in violent interactions with the other. There are demonstrable acts of mob tendencies from each side, where a mass of group B descended on an individual from group A. The crimes of each side are repugnant. Vehicular Murder ---------------- Then an individual drove a car through a crowd of people that opposed him, drastically escalating the level of force being used. Yes, this was heinous. Yes, it should be thoroughly dismissed as a repugnant act that has no place in civilized discourse. However, it doesn't dismiss or lessen the preceding illegality. There was wrong on each side; this was just more wrong. This was a grievous example of domestic terrorism. Warned in Advance ================= As reported by [Politico](http://www.politico.com/story/2017/08/29/charlottesville-violence-homeland-security-242140?lo=ap_e1), the Virginia Governor and Charlottesville mayor were warned in advanced of the potential for violence at the protest, from both the white supremacists and the anarchists, representatives of the extreme of either side. > > The Aug. 9 report by the DHS Office of Intelligence and Analysis was done in coordination with local, state and federal authorities at the Virginia Fusion Center. It stated that white supremacists and anti-fascist “antifa” extremists had clashed twice before in Charlottesville, at a white nationalist rally on May 13 and a Ku Klux Klan gathering July 7. At each event, “anarchist extremists” attacked protesters who had been issued permits, leading to fights, injuries, arrests and at least two felony charges of assault and battery. > > > Violence in Context =================== In the possibility that there is an implication from Trump's statements that the violence from either side is equivocal, it is important to fully establish the context in which the violence took place. This includes describing the nature of the violence, estimating the quantity of the violence, and considering the possibility that some of the violence was performed in self defense. Prior to the in depth analysis, focus on the Charlottesville Police Chief, who openly stated in press conference following the violence that the different groups were "[mutually combative.](https://www.washingtonpost.com/local/public-safety/charlottesville-police-chief-defends-officers-police-response-at-violent-rally/2017/08/14/23eff70e-8136-11e7-b359-15a3617c767b_story.html?utm_term=.1ad55bff469d)" *This will be everything but the murder, covered above.* Nature of --------- The event was scheduled to start at noon, but had to be canceled at 11.30 am due to the swelling level of violence. > > The Unite the Right rally was scheduled to start at noon but it never happened. By 11:30 a.m., with demonstrators and counter-protesters fighting in the streets, Charlottesville and Albemarle County officials declared a state of emergency and later declared the rally an illegal assembly, slowly clearing the park > > > Members of each side in this conflict open carried **firearms** at this protest (*A legal activity in Virginia*), depicted by these self proclaimed [AntiFa](https://www.nytimes.com/2017/08/14/us/who-were-the-counterprotesters-in-charlottesville.html) or these [Militia Men](https://www.washingtonpost.com/local/trafficandcommuting/militiamen-came-to-charlottesville-as-neutral-first-amendment-protectors-commander-says/2017/08/13/d3928794-8055-11e7-ab27-1a21a8e006ab_story.html?utm_term=.fb5372f644dd) wearing shirts with Confederate Flags. Thankfully, [Governor McCaulif](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says) stated in a NPR interview that no shots were fired during the event, though there are contradictory claims. **Skirmish weapons** were also on hand, as reported by the [Daily Progress](http://www.dailyprogress.com/news/local/ohio-man-charged-with-second-degree-murder-after-car-plows/article_ef4ba358-7f6a-11e7-84cf-8f840f442510.html) (*pay wall*), and referenced by the [New York Mag](http://nymag.com/daily/intelligencer/2017/08/state-of-emergency-in-va-after-white-nationalist-rally.html): > > “It could have been a lot worse today,” said Charlottesville Police Chief Al Thomas. “The premeditated violence is deplorable.” > > > Both sides came prepared for violence, wearing protective helmets, masks and carrying flags. When violence broke out, many of the flags were stripped from the wood handles and the handles were used as clubs. > > > Both sides brought street medics equipped with bandages and fluids for flushing eyes and skin afflicted with pepper spray. > > > This can be seen [here](https://youtu.be/67zCG-KPWfQ?t=4m55s), where the Alt-Right is marching with shields, helmets, and flags; in response, a fight breaks out between Antifa and the front line. Regrettably, who threw the first punch is obscured by the crowd. [At another point](https://youtu.be/67zCG-KPWfQ?t=6m54s), the Alt-right regroup, and are commanded back into action, shields and clubs used to batter the crowd. One of the counter protestors, [Jacob L. Smith](https://www.mediaite.com/online/one-of-the-men-arrested-in-charlottesville-was-a-counter-protestor-who-punched-a-female-reporter/), [punched](https://youtu.be/67zCG-KPWfQ?t=8m3s) a [Reporter Taylor Lorenz](http://www.newsleader.com/story/news/local/2017/08/14/reporter-punched-face-during-charlottesville-rally/565922001/) from The Hill for taping the events. A New York Times Reporter, Sheryl Gay Stolberg, [tweeted](https://twitter.com/SherylNYT/status/896575560650035200?ref_src=twsrc%5Etfw&ref_url=http%3A%2F%2Fwww.dailywire.com%2Fnews%2F19673%2Fny-times-reporter-admits-antifa-protesters-james-barrett%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_content%3D062316-news%26utm_campaign%3Dbenshapiro): > > The hard left seemed as hate-filled as alt-right. I saw club-wielding "antifa" beating white nationalists being led out of the park 2/2 > > > This lasted up until the backlash that she was "creating an equivalency." African American individual utilized an [improvised flamethrower](http://www.newyorker.com/culture/annals-of-appearances/an-image-of-revolutionary-fire-at-charlottesville?mbid=social_facebook_aud_dev_kw_paid-an-image-of-revolutionary-fire-at-charlottesville&kwp_0=496548&kwp_4=1784481&kwp_1=759637) against a large group of Alt-Right. His story, presented by the [Independent](http://www.independent.co.uk/news/world/americas/charlottesville-care-worker-neo-nazis-corey-long-flame-thrower-peaceful-protest-virginia-ku-klux-a7894161.html), sets the premise that he had attended the protest to heckle the Alt-Right, including claims that a gun was held to his head and a shot was fired at his feet. At a later point during the event, he was involved in an altercation where he used a spray can he found on the ground and a lighter in his pocket to hold off the crowd. This order of events (brandished firearm, discharged firearm, lunging with flag, and employment of improvised flame thrower), are disproved by a [video released](https://www.nytimes.com/2017/08/25/us/charlottesville-protest-police.html?mcubz=0) by the ACLU of Virginia. In this video, the order of events are depicted as: * Crowd is moving through * Spray starts from can directed towards faces of protestors * People walk away from the spray or cover their mouths * Spray is lit on fire, directed towards the protestors * Protestor A starts waving flag towards fire * Protestor B uses racial epithet, attempts to fire a shot: Gun Malfunction (expect no round chambered) * Protestor B manipulates slide, chambering round, fires shot into ground before Counter Protestor using improvised Flame thrower * Protestor B retreats. Quantity -------- The current dead - injured - missing values for the event are 3 - more than 36 - 0, as reported by [Charlottesville Officials](http://www.businessinsider.com/car-hits-counter-protesters-charlottesville-white-nationalist-rally-2017-8). This includes the tragic helicopter crash (2-0-0), the injuries from the vehicular murder (1-19-0), and individual altercations (0-more than 17-0). This does not account for people that were injured during individual altercations but did not seek medical aid, or associate their request for medical aid with the incident. Regrettably, there isn't a fullness of understanding for that total number of violent altercations. Self Defense ------------ It is possible that some of the violence that occurred during this protest was purely self defense. Virginia defines self defense, from charges of [Assault or Battery](http://www.livesaymyers.com/criminal-lawyers/assault-and-battery/), via common law and court decisions, as: > > Committing a battery with legal justification: hitting, pushing, scratching, etc. a person who placed you in “reasonable fear” of “imminent danger of bodily harm,” where your actions were “reasonably necessary to protect” yourself. An act that began as self-defense can cross the line into a separate crime of battery if you use excessive or unreasonable force in defending yourself. > > > From the same link, when considering that the police chief said many altercations between both groups were "mutually combative," all of those participants are wrong doers as described by SCOTUS case [Rowe V. United States](http://supreme.justia.com/cases/federal/us/164/546/). If an individual was to claim [Self Defense](http://www.livesaymyers.com/self-defense-assault-battery/) as an affirmative defense to charges, it is important that you either didn't instigate the altercation (fighting words, overt threats, etc.) or that you've made a good faith effort to abandon the fight. Domestic Terrorism ================== From the [Patriot Act, as understood by the ACLU](https://www.aclu.org/other/how-usa-patriot-act-redefines-domestic-terrorism), our definition is: > > A person engages in domestic terrorism if they do an act "dangerous to human life" that is a violation of the criminal laws of a state or the United States, if the act appears to be intended to: (i) intimidate or coerce a civilian population; (ii) influence the policy of a government by intimidation or coercion; or (iii) to affect the conduct of a government by mass destruction, assassination or kidnapping. Additionally, the acts have to occur primarily within the territorial jurisdiction of the United States and if they do not, may be regarded as international terrorism. > > > Driving a car through a crowd of people that were offering a counter protest to your activities fits this definition. Though it should be noted that the violence as speech from both sides, which lead to the Police force terminating the Unite the Right protest and calling for the groups to disperse, could also fit within this definition. Consider reporting from [Politico](http://www.politico.com/story/2017/09/01/antifa-charlottesville-violence-fbi-242235?lo=ap_c1) detailing their activities as "domestic terror violence." This is not a media term; it is the legal definition by which the events of Charlottesville should be judged. All sides aren't violent in a riot; Simplistically there were two sides at this fight, but that doesn't account for the idiots or peaceful folk that joined into the fight with out intentions to resort to violence. this allows for the possibility that: > > There were leftist protest who were intent on peaceably protesting the Alt-Right Antics. > > > There were some misguided idiots from the right who were there for "free speech" reasons. *Note: In today's climate, look who is standing next to you. If you're beside people that embrace white power, you're going to be associated with nazis.* > > > Who are the Nazis? ================== In the context of this answer, the Nazis are the violent extremes of the Unite the Right Protest. This includes those chanting Hail Victory, performing the colloquially recognized Nazi Salute, or openly displaying White Supremacy symbolism (white pride flags). This answer rejects the implication that *all of the right* are Nazis.
There were confrontation and violence (small skirmishes) between the 2 sides; but it was minimal (other than the car attack) This is the only link I could find about arrests, it does not say if there were from one side or the other. <http://www.cbsnews.com/news/white-nationalists-rally-charlottesville-live-updates/> > > **Virginia State Police said Saturday night that three people had been arrested in connection to the rally**. Troy Dunigan, 21, of Chattanooga, Tenn., was charged with disorderly conduct; Jacob L. Smith, 21, of Louisa, Va., was charged with misdemeanor assault and battery; and James M. O'Brien, 44, of Gainesville, Fla., was charged with carrying a concealed weapon, Virginia State Police said. > > >
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
There were confrontation and violence (small skirmishes) between the 2 sides; but it was minimal (other than the car attack) This is the only link I could find about arrests, it does not say if there were from one side or the other. <http://www.cbsnews.com/news/white-nationalists-rally-charlottesville-live-updates/> > > **Virginia State Police said Saturday night that three people had been arrested in connection to the rally**. Troy Dunigan, 21, of Chattanooga, Tenn., was charged with disorderly conduct; Jacob L. Smith, 21, of Louisa, Va., was charged with misdemeanor assault and battery; and James M. O'Brien, 44, of Gainesville, Fla., was charged with carrying a concealed weapon, Virginia State Police said. > > >
How about we let a relatively objective number speak? According to Governor McAuliffe, from multiple [interviews Monday](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says), not a single "alt-right" protestor ended up dead or hospitalized from the rally.\* He seemed quite proud of that. According to news sources, [1 person died and 19 were hospitalized](http://www.cbsnews.com/news/charlottesville-white-supremacist-protest-victims-heather-heyer-friends/) as a result of the violence at the rallies. That's of course not counting the two officers who died in a helicopter crash monitoring the protests. A wag would point out here that 19 (or one) divided by zero is infinity. But even without playing statistical games like that, its pretty clear from the numbers that nearly all (if not all) of the serious violence was being carried out by the alt-right. \* - This could **really** use independent confirmation.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
According to the Charlottesville Chief of Police, there were "mutually engaged combatants". His statement is available for viewing [here](https://www.youtube.com/watch?v=-UgRGf6PJOA). When pressed on the question of assigning blame, he maintained his neutrality on that matter and reiterated that there were "mutually engaged combatants".
It's easy to find incidences of "right" wing violence in the left wing media. If you want to find left wing violence, you have to look in the right wing media. E.g. [Breitbart](http://www.breitbart.com/big-government/2017/08/12/female-reporter-for-the-hill-allegedly-punched-by-antifa-protester-in-charlottesville/) reports that a female reporter for The Hill was punched in the face: > > A female reporter for the Hill was allegedly punched by an “Antifa” protester in the wake of a deadly car attack in Charlottesville, Virginia Saturday as she tried to film the ensuing chaos. > > > And quotes her twitter feed: > > > > > > Turns out the guy who punched me in the face for recording after the incident already had a warrant out for his arrest. So he's being held. > > > > > > > > > — Taylor Lorenz (@TaylorLorenz) [August 12, 2017](https://twitter.com/TaylorLorenz/status/896450940995346432) > > > That was purportedly posted from the police station where she was waiting to make her report. I have yet to hear anyone in the government denounce that bit of violence. Other reports agree that counter protesters (left wing) were deliberately inciting the protesters ("right" wing). E.g. [The Times of Israel](http://www.timesofisrael.com/counter-protesters-face-off-with-white-nationalists-in-virginia-ahead-of-far-right-rally/) reported: > > Earlier, the counter-demonstrators shouted “From the Midwest to the South, punch a Nazi in the mouth,” and “Nazi scum” at far-right attendees gathering at Emancipation Park in the city where the rally will be held. > > > It's worth noting that while all Nazis are white nationalists, not all white nationalists are Nazis. So when you see people refer to the protesters as Nazis, they are using a derogatory slur. The protest was about a statue of Robert E. Lee being scheduled for removal. Lee was a Confederate general during the Civil War. He died decades before the Nazis came to be. While remembered as allying with racists during the Civil War, he was not a Nazi. He did not advocate genocide against Jews, blacks, or anyone. Some people who support him now may be Nazis.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
Bottom Line Up Front ==================== Yes, there was violence perpetrated by both AntiFa and the White Supremacists. [Ben Shapiro's](https://www.youtube.com/watch?v=67zCG-KPWfQ) show the day after properly highlights the violence on each side (specific parts showing violence will be referenced below). That there was violence on one side does not dismiss or excuse the violence on the other side. That there was violence on both sides does not excuse the domestic terrorism incident perpetrated via vehicular murder. Making it Abundantly Clear ========================== Many are highlighting a difference in the **magnitude** of the violence that was perpetrated by both sides, as if to insinuate that because the member of one side committed vehicular murder, the severity of the violence by the other side is lessened. This establishes a logical fallacy. To start, consider the course of events without the pinnacle of violence: each side had actors that engaged in violent interactions with the other. There are demonstrable acts of mob tendencies from each side, where a mass of group B descended on an individual from group A. The crimes of each side are repugnant. Vehicular Murder ---------------- Then an individual drove a car through a crowd of people that opposed him, drastically escalating the level of force being used. Yes, this was heinous. Yes, it should be thoroughly dismissed as a repugnant act that has no place in civilized discourse. However, it doesn't dismiss or lessen the preceding illegality. There was wrong on each side; this was just more wrong. This was a grievous example of domestic terrorism. Warned in Advance ================= As reported by [Politico](http://www.politico.com/story/2017/08/29/charlottesville-violence-homeland-security-242140?lo=ap_e1), the Virginia Governor and Charlottesville mayor were warned in advanced of the potential for violence at the protest, from both the white supremacists and the anarchists, representatives of the extreme of either side. > > The Aug. 9 report by the DHS Office of Intelligence and Analysis was done in coordination with local, state and federal authorities at the Virginia Fusion Center. It stated that white supremacists and anti-fascist “antifa” extremists had clashed twice before in Charlottesville, at a white nationalist rally on May 13 and a Ku Klux Klan gathering July 7. At each event, “anarchist extremists” attacked protesters who had been issued permits, leading to fights, injuries, arrests and at least two felony charges of assault and battery. > > > Violence in Context =================== In the possibility that there is an implication from Trump's statements that the violence from either side is equivocal, it is important to fully establish the context in which the violence took place. This includes describing the nature of the violence, estimating the quantity of the violence, and considering the possibility that some of the violence was performed in self defense. Prior to the in depth analysis, focus on the Charlottesville Police Chief, who openly stated in press conference following the violence that the different groups were "[mutually combative.](https://www.washingtonpost.com/local/public-safety/charlottesville-police-chief-defends-officers-police-response-at-violent-rally/2017/08/14/23eff70e-8136-11e7-b359-15a3617c767b_story.html?utm_term=.1ad55bff469d)" *This will be everything but the murder, covered above.* Nature of --------- The event was scheduled to start at noon, but had to be canceled at 11.30 am due to the swelling level of violence. > > The Unite the Right rally was scheduled to start at noon but it never happened. By 11:30 a.m., with demonstrators and counter-protesters fighting in the streets, Charlottesville and Albemarle County officials declared a state of emergency and later declared the rally an illegal assembly, slowly clearing the park > > > Members of each side in this conflict open carried **firearms** at this protest (*A legal activity in Virginia*), depicted by these self proclaimed [AntiFa](https://www.nytimes.com/2017/08/14/us/who-were-the-counterprotesters-in-charlottesville.html) or these [Militia Men](https://www.washingtonpost.com/local/trafficandcommuting/militiamen-came-to-charlottesville-as-neutral-first-amendment-protectors-commander-says/2017/08/13/d3928794-8055-11e7-ab27-1a21a8e006ab_story.html?utm_term=.fb5372f644dd) wearing shirts with Confederate Flags. Thankfully, [Governor McCaulif](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says) stated in a NPR interview that no shots were fired during the event, though there are contradictory claims. **Skirmish weapons** were also on hand, as reported by the [Daily Progress](http://www.dailyprogress.com/news/local/ohio-man-charged-with-second-degree-murder-after-car-plows/article_ef4ba358-7f6a-11e7-84cf-8f840f442510.html) (*pay wall*), and referenced by the [New York Mag](http://nymag.com/daily/intelligencer/2017/08/state-of-emergency-in-va-after-white-nationalist-rally.html): > > “It could have been a lot worse today,” said Charlottesville Police Chief Al Thomas. “The premeditated violence is deplorable.” > > > Both sides came prepared for violence, wearing protective helmets, masks and carrying flags. When violence broke out, many of the flags were stripped from the wood handles and the handles were used as clubs. > > > Both sides brought street medics equipped with bandages and fluids for flushing eyes and skin afflicted with pepper spray. > > > This can be seen [here](https://youtu.be/67zCG-KPWfQ?t=4m55s), where the Alt-Right is marching with shields, helmets, and flags; in response, a fight breaks out between Antifa and the front line. Regrettably, who threw the first punch is obscured by the crowd. [At another point](https://youtu.be/67zCG-KPWfQ?t=6m54s), the Alt-right regroup, and are commanded back into action, shields and clubs used to batter the crowd. One of the counter protestors, [Jacob L. Smith](https://www.mediaite.com/online/one-of-the-men-arrested-in-charlottesville-was-a-counter-protestor-who-punched-a-female-reporter/), [punched](https://youtu.be/67zCG-KPWfQ?t=8m3s) a [Reporter Taylor Lorenz](http://www.newsleader.com/story/news/local/2017/08/14/reporter-punched-face-during-charlottesville-rally/565922001/) from The Hill for taping the events. A New York Times Reporter, Sheryl Gay Stolberg, [tweeted](https://twitter.com/SherylNYT/status/896575560650035200?ref_src=twsrc%5Etfw&ref_url=http%3A%2F%2Fwww.dailywire.com%2Fnews%2F19673%2Fny-times-reporter-admits-antifa-protesters-james-barrett%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_content%3D062316-news%26utm_campaign%3Dbenshapiro): > > The hard left seemed as hate-filled as alt-right. I saw club-wielding "antifa" beating white nationalists being led out of the park 2/2 > > > This lasted up until the backlash that she was "creating an equivalency." African American individual utilized an [improvised flamethrower](http://www.newyorker.com/culture/annals-of-appearances/an-image-of-revolutionary-fire-at-charlottesville?mbid=social_facebook_aud_dev_kw_paid-an-image-of-revolutionary-fire-at-charlottesville&kwp_0=496548&kwp_4=1784481&kwp_1=759637) against a large group of Alt-Right. His story, presented by the [Independent](http://www.independent.co.uk/news/world/americas/charlottesville-care-worker-neo-nazis-corey-long-flame-thrower-peaceful-protest-virginia-ku-klux-a7894161.html), sets the premise that he had attended the protest to heckle the Alt-Right, including claims that a gun was held to his head and a shot was fired at his feet. At a later point during the event, he was involved in an altercation where he used a spray can he found on the ground and a lighter in his pocket to hold off the crowd. This order of events (brandished firearm, discharged firearm, lunging with flag, and employment of improvised flame thrower), are disproved by a [video released](https://www.nytimes.com/2017/08/25/us/charlottesville-protest-police.html?mcubz=0) by the ACLU of Virginia. In this video, the order of events are depicted as: * Crowd is moving through * Spray starts from can directed towards faces of protestors * People walk away from the spray or cover their mouths * Spray is lit on fire, directed towards the protestors * Protestor A starts waving flag towards fire * Protestor B uses racial epithet, attempts to fire a shot: Gun Malfunction (expect no round chambered) * Protestor B manipulates slide, chambering round, fires shot into ground before Counter Protestor using improvised Flame thrower * Protestor B retreats. Quantity -------- The current dead - injured - missing values for the event are 3 - more than 36 - 0, as reported by [Charlottesville Officials](http://www.businessinsider.com/car-hits-counter-protesters-charlottesville-white-nationalist-rally-2017-8). This includes the tragic helicopter crash (2-0-0), the injuries from the vehicular murder (1-19-0), and individual altercations (0-more than 17-0). This does not account for people that were injured during individual altercations but did not seek medical aid, or associate their request for medical aid with the incident. Regrettably, there isn't a fullness of understanding for that total number of violent altercations. Self Defense ------------ It is possible that some of the violence that occurred during this protest was purely self defense. Virginia defines self defense, from charges of [Assault or Battery](http://www.livesaymyers.com/criminal-lawyers/assault-and-battery/), via common law and court decisions, as: > > Committing a battery with legal justification: hitting, pushing, scratching, etc. a person who placed you in “reasonable fear” of “imminent danger of bodily harm,” where your actions were “reasonably necessary to protect” yourself. An act that began as self-defense can cross the line into a separate crime of battery if you use excessive or unreasonable force in defending yourself. > > > From the same link, when considering that the police chief said many altercations between both groups were "mutually combative," all of those participants are wrong doers as described by SCOTUS case [Rowe V. United States](http://supreme.justia.com/cases/federal/us/164/546/). If an individual was to claim [Self Defense](http://www.livesaymyers.com/self-defense-assault-battery/) as an affirmative defense to charges, it is important that you either didn't instigate the altercation (fighting words, overt threats, etc.) or that you've made a good faith effort to abandon the fight. Domestic Terrorism ================== From the [Patriot Act, as understood by the ACLU](https://www.aclu.org/other/how-usa-patriot-act-redefines-domestic-terrorism), our definition is: > > A person engages in domestic terrorism if they do an act "dangerous to human life" that is a violation of the criminal laws of a state or the United States, if the act appears to be intended to: (i) intimidate or coerce a civilian population; (ii) influence the policy of a government by intimidation or coercion; or (iii) to affect the conduct of a government by mass destruction, assassination or kidnapping. Additionally, the acts have to occur primarily within the territorial jurisdiction of the United States and if they do not, may be regarded as international terrorism. > > > Driving a car through a crowd of people that were offering a counter protest to your activities fits this definition. Though it should be noted that the violence as speech from both sides, which lead to the Police force terminating the Unite the Right protest and calling for the groups to disperse, could also fit within this definition. Consider reporting from [Politico](http://www.politico.com/story/2017/09/01/antifa-charlottesville-violence-fbi-242235?lo=ap_c1) detailing their activities as "domestic terror violence." This is not a media term; it is the legal definition by which the events of Charlottesville should be judged. All sides aren't violent in a riot; Simplistically there were two sides at this fight, but that doesn't account for the idiots or peaceful folk that joined into the fight with out intentions to resort to violence. this allows for the possibility that: > > There were leftist protest who were intent on peaceably protesting the Alt-Right Antics. > > > There were some misguided idiots from the right who were there for "free speech" reasons. *Note: In today's climate, look who is standing next to you. If you're beside people that embrace white power, you're going to be associated with nazis.* > > > Who are the Nazis? ================== In the context of this answer, the Nazis are the violent extremes of the Unite the Right Protest. This includes those chanting Hail Victory, performing the colloquially recognized Nazi Salute, or openly displaying White Supremacy symbolism (white pride flags). This answer rejects the implication that *all of the right* are Nazis.
According to the Charlottesville Chief of Police, there were "mutually engaged combatants". His statement is available for viewing [here](https://www.youtube.com/watch?v=-UgRGf6PJOA). When pressed on the question of assigning blame, he maintained his neutrality on that matter and reiterated that there were "mutually engaged combatants".
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
According to the Charlottesville Chief of Police, there were "mutually engaged combatants". His statement is available for viewing [here](https://www.youtube.com/watch?v=-UgRGf6PJOA). When pressed on the question of assigning blame, he maintained his neutrality on that matter and reiterated that there were "mutually engaged combatants".
How about we let a relatively objective number speak? According to Governor McAuliffe, from multiple [interviews Monday](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says), not a single "alt-right" protestor ended up dead or hospitalized from the rally.\* He seemed quite proud of that. According to news sources, [1 person died and 19 were hospitalized](http://www.cbsnews.com/news/charlottesville-white-supremacist-protest-victims-heather-heyer-friends/) as a result of the violence at the rallies. That's of course not counting the two officers who died in a helicopter crash monitoring the protests. A wag would point out here that 19 (or one) divided by zero is infinity. But even without playing statistical games like that, its pretty clear from the numbers that nearly all (if not all) of the serious violence was being carried out by the alt-right. \* - This could **really** use independent confirmation.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
Bottom Line Up Front ==================== Yes, there was violence perpetrated by both AntiFa and the White Supremacists. [Ben Shapiro's](https://www.youtube.com/watch?v=67zCG-KPWfQ) show the day after properly highlights the violence on each side (specific parts showing violence will be referenced below). That there was violence on one side does not dismiss or excuse the violence on the other side. That there was violence on both sides does not excuse the domestic terrorism incident perpetrated via vehicular murder. Making it Abundantly Clear ========================== Many are highlighting a difference in the **magnitude** of the violence that was perpetrated by both sides, as if to insinuate that because the member of one side committed vehicular murder, the severity of the violence by the other side is lessened. This establishes a logical fallacy. To start, consider the course of events without the pinnacle of violence: each side had actors that engaged in violent interactions with the other. There are demonstrable acts of mob tendencies from each side, where a mass of group B descended on an individual from group A. The crimes of each side are repugnant. Vehicular Murder ---------------- Then an individual drove a car through a crowd of people that opposed him, drastically escalating the level of force being used. Yes, this was heinous. Yes, it should be thoroughly dismissed as a repugnant act that has no place in civilized discourse. However, it doesn't dismiss or lessen the preceding illegality. There was wrong on each side; this was just more wrong. This was a grievous example of domestic terrorism. Warned in Advance ================= As reported by [Politico](http://www.politico.com/story/2017/08/29/charlottesville-violence-homeland-security-242140?lo=ap_e1), the Virginia Governor and Charlottesville mayor were warned in advanced of the potential for violence at the protest, from both the white supremacists and the anarchists, representatives of the extreme of either side. > > The Aug. 9 report by the DHS Office of Intelligence and Analysis was done in coordination with local, state and federal authorities at the Virginia Fusion Center. It stated that white supremacists and anti-fascist “antifa” extremists had clashed twice before in Charlottesville, at a white nationalist rally on May 13 and a Ku Klux Klan gathering July 7. At each event, “anarchist extremists” attacked protesters who had been issued permits, leading to fights, injuries, arrests and at least two felony charges of assault and battery. > > > Violence in Context =================== In the possibility that there is an implication from Trump's statements that the violence from either side is equivocal, it is important to fully establish the context in which the violence took place. This includes describing the nature of the violence, estimating the quantity of the violence, and considering the possibility that some of the violence was performed in self defense. Prior to the in depth analysis, focus on the Charlottesville Police Chief, who openly stated in press conference following the violence that the different groups were "[mutually combative.](https://www.washingtonpost.com/local/public-safety/charlottesville-police-chief-defends-officers-police-response-at-violent-rally/2017/08/14/23eff70e-8136-11e7-b359-15a3617c767b_story.html?utm_term=.1ad55bff469d)" *This will be everything but the murder, covered above.* Nature of --------- The event was scheduled to start at noon, but had to be canceled at 11.30 am due to the swelling level of violence. > > The Unite the Right rally was scheduled to start at noon but it never happened. By 11:30 a.m., with demonstrators and counter-protesters fighting in the streets, Charlottesville and Albemarle County officials declared a state of emergency and later declared the rally an illegal assembly, slowly clearing the park > > > Members of each side in this conflict open carried **firearms** at this protest (*A legal activity in Virginia*), depicted by these self proclaimed [AntiFa](https://www.nytimes.com/2017/08/14/us/who-were-the-counterprotesters-in-charlottesville.html) or these [Militia Men](https://www.washingtonpost.com/local/trafficandcommuting/militiamen-came-to-charlottesville-as-neutral-first-amendment-protectors-commander-says/2017/08/13/d3928794-8055-11e7-ab27-1a21a8e006ab_story.html?utm_term=.fb5372f644dd) wearing shirts with Confederate Flags. Thankfully, [Governor McCaulif](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says) stated in a NPR interview that no shots were fired during the event, though there are contradictory claims. **Skirmish weapons** were also on hand, as reported by the [Daily Progress](http://www.dailyprogress.com/news/local/ohio-man-charged-with-second-degree-murder-after-car-plows/article_ef4ba358-7f6a-11e7-84cf-8f840f442510.html) (*pay wall*), and referenced by the [New York Mag](http://nymag.com/daily/intelligencer/2017/08/state-of-emergency-in-va-after-white-nationalist-rally.html): > > “It could have been a lot worse today,” said Charlottesville Police Chief Al Thomas. “The premeditated violence is deplorable.” > > > Both sides came prepared for violence, wearing protective helmets, masks and carrying flags. When violence broke out, many of the flags were stripped from the wood handles and the handles were used as clubs. > > > Both sides brought street medics equipped with bandages and fluids for flushing eyes and skin afflicted with pepper spray. > > > This can be seen [here](https://youtu.be/67zCG-KPWfQ?t=4m55s), where the Alt-Right is marching with shields, helmets, and flags; in response, a fight breaks out between Antifa and the front line. Regrettably, who threw the first punch is obscured by the crowd. [At another point](https://youtu.be/67zCG-KPWfQ?t=6m54s), the Alt-right regroup, and are commanded back into action, shields and clubs used to batter the crowd. One of the counter protestors, [Jacob L. Smith](https://www.mediaite.com/online/one-of-the-men-arrested-in-charlottesville-was-a-counter-protestor-who-punched-a-female-reporter/), [punched](https://youtu.be/67zCG-KPWfQ?t=8m3s) a [Reporter Taylor Lorenz](http://www.newsleader.com/story/news/local/2017/08/14/reporter-punched-face-during-charlottesville-rally/565922001/) from The Hill for taping the events. A New York Times Reporter, Sheryl Gay Stolberg, [tweeted](https://twitter.com/SherylNYT/status/896575560650035200?ref_src=twsrc%5Etfw&ref_url=http%3A%2F%2Fwww.dailywire.com%2Fnews%2F19673%2Fny-times-reporter-admits-antifa-protesters-james-barrett%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_content%3D062316-news%26utm_campaign%3Dbenshapiro): > > The hard left seemed as hate-filled as alt-right. I saw club-wielding "antifa" beating white nationalists being led out of the park 2/2 > > > This lasted up until the backlash that she was "creating an equivalency." African American individual utilized an [improvised flamethrower](http://www.newyorker.com/culture/annals-of-appearances/an-image-of-revolutionary-fire-at-charlottesville?mbid=social_facebook_aud_dev_kw_paid-an-image-of-revolutionary-fire-at-charlottesville&kwp_0=496548&kwp_4=1784481&kwp_1=759637) against a large group of Alt-Right. His story, presented by the [Independent](http://www.independent.co.uk/news/world/americas/charlottesville-care-worker-neo-nazis-corey-long-flame-thrower-peaceful-protest-virginia-ku-klux-a7894161.html), sets the premise that he had attended the protest to heckle the Alt-Right, including claims that a gun was held to his head and a shot was fired at his feet. At a later point during the event, he was involved in an altercation where he used a spray can he found on the ground and a lighter in his pocket to hold off the crowd. This order of events (brandished firearm, discharged firearm, lunging with flag, and employment of improvised flame thrower), are disproved by a [video released](https://www.nytimes.com/2017/08/25/us/charlottesville-protest-police.html?mcubz=0) by the ACLU of Virginia. In this video, the order of events are depicted as: * Crowd is moving through * Spray starts from can directed towards faces of protestors * People walk away from the spray or cover their mouths * Spray is lit on fire, directed towards the protestors * Protestor A starts waving flag towards fire * Protestor B uses racial epithet, attempts to fire a shot: Gun Malfunction (expect no round chambered) * Protestor B manipulates slide, chambering round, fires shot into ground before Counter Protestor using improvised Flame thrower * Protestor B retreats. Quantity -------- The current dead - injured - missing values for the event are 3 - more than 36 - 0, as reported by [Charlottesville Officials](http://www.businessinsider.com/car-hits-counter-protesters-charlottesville-white-nationalist-rally-2017-8). This includes the tragic helicopter crash (2-0-0), the injuries from the vehicular murder (1-19-0), and individual altercations (0-more than 17-0). This does not account for people that were injured during individual altercations but did not seek medical aid, or associate their request for medical aid with the incident. Regrettably, there isn't a fullness of understanding for that total number of violent altercations. Self Defense ------------ It is possible that some of the violence that occurred during this protest was purely self defense. Virginia defines self defense, from charges of [Assault or Battery](http://www.livesaymyers.com/criminal-lawyers/assault-and-battery/), via common law and court decisions, as: > > Committing a battery with legal justification: hitting, pushing, scratching, etc. a person who placed you in “reasonable fear” of “imminent danger of bodily harm,” where your actions were “reasonably necessary to protect” yourself. An act that began as self-defense can cross the line into a separate crime of battery if you use excessive or unreasonable force in defending yourself. > > > From the same link, when considering that the police chief said many altercations between both groups were "mutually combative," all of those participants are wrong doers as described by SCOTUS case [Rowe V. United States](http://supreme.justia.com/cases/federal/us/164/546/). If an individual was to claim [Self Defense](http://www.livesaymyers.com/self-defense-assault-battery/) as an affirmative defense to charges, it is important that you either didn't instigate the altercation (fighting words, overt threats, etc.) or that you've made a good faith effort to abandon the fight. Domestic Terrorism ================== From the [Patriot Act, as understood by the ACLU](https://www.aclu.org/other/how-usa-patriot-act-redefines-domestic-terrorism), our definition is: > > A person engages in domestic terrorism if they do an act "dangerous to human life" that is a violation of the criminal laws of a state or the United States, if the act appears to be intended to: (i) intimidate or coerce a civilian population; (ii) influence the policy of a government by intimidation or coercion; or (iii) to affect the conduct of a government by mass destruction, assassination or kidnapping. Additionally, the acts have to occur primarily within the territorial jurisdiction of the United States and if they do not, may be regarded as international terrorism. > > > Driving a car through a crowd of people that were offering a counter protest to your activities fits this definition. Though it should be noted that the violence as speech from both sides, which lead to the Police force terminating the Unite the Right protest and calling for the groups to disperse, could also fit within this definition. Consider reporting from [Politico](http://www.politico.com/story/2017/09/01/antifa-charlottesville-violence-fbi-242235?lo=ap_c1) detailing their activities as "domestic terror violence." This is not a media term; it is the legal definition by which the events of Charlottesville should be judged. All sides aren't violent in a riot; Simplistically there were two sides at this fight, but that doesn't account for the idiots or peaceful folk that joined into the fight with out intentions to resort to violence. this allows for the possibility that: > > There were leftist protest who were intent on peaceably protesting the Alt-Right Antics. > > > There were some misguided idiots from the right who were there for "free speech" reasons. *Note: In today's climate, look who is standing next to you. If you're beside people that embrace white power, you're going to be associated with nazis.* > > > Who are the Nazis? ================== In the context of this answer, the Nazis are the violent extremes of the Unite the Right Protest. This includes those chanting Hail Victory, performing the colloquially recognized Nazi Salute, or openly displaying White Supremacy symbolism (white pride flags). This answer rejects the implication that *all of the right* are Nazis.
It's easy to find incidences of "right" wing violence in the left wing media. If you want to find left wing violence, you have to look in the right wing media. E.g. [Breitbart](http://www.breitbart.com/big-government/2017/08/12/female-reporter-for-the-hill-allegedly-punched-by-antifa-protester-in-charlottesville/) reports that a female reporter for The Hill was punched in the face: > > A female reporter for the Hill was allegedly punched by an “Antifa” protester in the wake of a deadly car attack in Charlottesville, Virginia Saturday as she tried to film the ensuing chaos. > > > And quotes her twitter feed: > > > > > > Turns out the guy who punched me in the face for recording after the incident already had a warrant out for his arrest. So he's being held. > > > > > > > > > — Taylor Lorenz (@TaylorLorenz) [August 12, 2017](https://twitter.com/TaylorLorenz/status/896450940995346432) > > > That was purportedly posted from the police station where she was waiting to make her report. I have yet to hear anyone in the government denounce that bit of violence. Other reports agree that counter protesters (left wing) were deliberately inciting the protesters ("right" wing). E.g. [The Times of Israel](http://www.timesofisrael.com/counter-protesters-face-off-with-white-nationalists-in-virginia-ahead-of-far-right-rally/) reported: > > Earlier, the counter-demonstrators shouted “From the Midwest to the South, punch a Nazi in the mouth,” and “Nazi scum” at far-right attendees gathering at Emancipation Park in the city where the rally will be held. > > > It's worth noting that while all Nazis are white nationalists, not all white nationalists are Nazis. So when you see people refer to the protesters as Nazis, they are using a derogatory slur. The protest was about a statue of Robert E. Lee being scheduled for removal. Lee was a Confederate general during the Civil War. He died decades before the Nazis came to be. While remembered as allying with racists during the Civil War, he was not a Nazi. He did not advocate genocide against Jews, blacks, or anyone. Some people who support him now may be Nazis.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
How about we let a relatively objective number speak? According to Governor McAuliffe, from multiple [interviews Monday](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says), not a single "alt-right" protestor ended up dead or hospitalized from the rally.\* He seemed quite proud of that. According to news sources, [1 person died and 19 were hospitalized](http://www.cbsnews.com/news/charlottesville-white-supremacist-protest-victims-heather-heyer-friends/) as a result of the violence at the rallies. That's of course not counting the two officers who died in a helicopter crash monitoring the protests. A wag would point out here that 19 (or one) divided by zero is infinity. But even without playing statistical games like that, its pretty clear from the numbers that nearly all (if not all) of the serious violence was being carried out by the alt-right. \* - This could **really** use independent confirmation.
It's easy to find incidences of "right" wing violence in the left wing media. If you want to find left wing violence, you have to look in the right wing media. E.g. [Breitbart](http://www.breitbart.com/big-government/2017/08/12/female-reporter-for-the-hill-allegedly-punched-by-antifa-protester-in-charlottesville/) reports that a female reporter for The Hill was punched in the face: > > A female reporter for the Hill was allegedly punched by an “Antifa” protester in the wake of a deadly car attack in Charlottesville, Virginia Saturday as she tried to film the ensuing chaos. > > > And quotes her twitter feed: > > > > > > Turns out the guy who punched me in the face for recording after the incident already had a warrant out for his arrest. So he's being held. > > > > > > > > > — Taylor Lorenz (@TaylorLorenz) [August 12, 2017](https://twitter.com/TaylorLorenz/status/896450940995346432) > > > That was purportedly posted from the police station where she was waiting to make her report. I have yet to hear anyone in the government denounce that bit of violence. Other reports agree that counter protesters (left wing) were deliberately inciting the protesters ("right" wing). E.g. [The Times of Israel](http://www.timesofisrael.com/counter-protesters-face-off-with-white-nationalists-in-virginia-ahead-of-far-right-rally/) reported: > > Earlier, the counter-demonstrators shouted “From the Midwest to the South, punch a Nazi in the mouth,” and “Nazi scum” at far-right attendees gathering at Emancipation Park in the city where the rally will be held. > > > It's worth noting that while all Nazis are white nationalists, not all white nationalists are Nazis. So when you see people refer to the protesters as Nazis, they are using a derogatory slur. The protest was about a statue of Robert E. Lee being scheduled for removal. Lee was a Confederate general during the Civil War. He died decades before the Nazis came to be. While remembered as allying with racists during the Civil War, he was not a Nazi. He did not advocate genocide against Jews, blacks, or anyone. Some people who support him now may be Nazis.
23,667
Today, President Trump claimed that there was violence on "both sides," and that alt-left and alt-right both shared blame in the incidents at Charlottesville, Virginia. Is this factually accurate? I'm not aware of any alt-left protestors being arrested, nor have seen any alt-left protesters attacking alt-right protesters.
2017/08/15
[ "https://politics.stackexchange.com/questions/23667", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/15576/" ]
Bottom Line Up Front ==================== Yes, there was violence perpetrated by both AntiFa and the White Supremacists. [Ben Shapiro's](https://www.youtube.com/watch?v=67zCG-KPWfQ) show the day after properly highlights the violence on each side (specific parts showing violence will be referenced below). That there was violence on one side does not dismiss or excuse the violence on the other side. That there was violence on both sides does not excuse the domestic terrorism incident perpetrated via vehicular murder. Making it Abundantly Clear ========================== Many are highlighting a difference in the **magnitude** of the violence that was perpetrated by both sides, as if to insinuate that because the member of one side committed vehicular murder, the severity of the violence by the other side is lessened. This establishes a logical fallacy. To start, consider the course of events without the pinnacle of violence: each side had actors that engaged in violent interactions with the other. There are demonstrable acts of mob tendencies from each side, where a mass of group B descended on an individual from group A. The crimes of each side are repugnant. Vehicular Murder ---------------- Then an individual drove a car through a crowd of people that opposed him, drastically escalating the level of force being used. Yes, this was heinous. Yes, it should be thoroughly dismissed as a repugnant act that has no place in civilized discourse. However, it doesn't dismiss or lessen the preceding illegality. There was wrong on each side; this was just more wrong. This was a grievous example of domestic terrorism. Warned in Advance ================= As reported by [Politico](http://www.politico.com/story/2017/08/29/charlottesville-violence-homeland-security-242140?lo=ap_e1), the Virginia Governor and Charlottesville mayor were warned in advanced of the potential for violence at the protest, from both the white supremacists and the anarchists, representatives of the extreme of either side. > > The Aug. 9 report by the DHS Office of Intelligence and Analysis was done in coordination with local, state and federal authorities at the Virginia Fusion Center. It stated that white supremacists and anti-fascist “antifa” extremists had clashed twice before in Charlottesville, at a white nationalist rally on May 13 and a Ku Klux Klan gathering July 7. At each event, “anarchist extremists” attacked protesters who had been issued permits, leading to fights, injuries, arrests and at least two felony charges of assault and battery. > > > Violence in Context =================== In the possibility that there is an implication from Trump's statements that the violence from either side is equivocal, it is important to fully establish the context in which the violence took place. This includes describing the nature of the violence, estimating the quantity of the violence, and considering the possibility that some of the violence was performed in self defense. Prior to the in depth analysis, focus on the Charlottesville Police Chief, who openly stated in press conference following the violence that the different groups were "[mutually combative.](https://www.washingtonpost.com/local/public-safety/charlottesville-police-chief-defends-officers-police-response-at-violent-rally/2017/08/14/23eff70e-8136-11e7-b359-15a3617c767b_story.html?utm_term=.1ad55bff469d)" *This will be everything but the murder, covered above.* Nature of --------- The event was scheduled to start at noon, but had to be canceled at 11.30 am due to the swelling level of violence. > > The Unite the Right rally was scheduled to start at noon but it never happened. By 11:30 a.m., with demonstrators and counter-protesters fighting in the streets, Charlottesville and Albemarle County officials declared a state of emergency and later declared the rally an illegal assembly, slowly clearing the park > > > Members of each side in this conflict open carried **firearms** at this protest (*A legal activity in Virginia*), depicted by these self proclaimed [AntiFa](https://www.nytimes.com/2017/08/14/us/who-were-the-counterprotesters-in-charlottesville.html) or these [Militia Men](https://www.washingtonpost.com/local/trafficandcommuting/militiamen-came-to-charlottesville-as-neutral-first-amendment-protectors-commander-says/2017/08/13/d3928794-8055-11e7-ab27-1a21a8e006ab_story.html?utm_term=.fb5372f644dd) wearing shirts with Confederate Flags. Thankfully, [Governor McCaulif](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says) stated in a NPR interview that no shots were fired during the event, though there are contradictory claims. **Skirmish weapons** were also on hand, as reported by the [Daily Progress](http://www.dailyprogress.com/news/local/ohio-man-charged-with-second-degree-murder-after-car-plows/article_ef4ba358-7f6a-11e7-84cf-8f840f442510.html) (*pay wall*), and referenced by the [New York Mag](http://nymag.com/daily/intelligencer/2017/08/state-of-emergency-in-va-after-white-nationalist-rally.html): > > “It could have been a lot worse today,” said Charlottesville Police Chief Al Thomas. “The premeditated violence is deplorable.” > > > Both sides came prepared for violence, wearing protective helmets, masks and carrying flags. When violence broke out, many of the flags were stripped from the wood handles and the handles were used as clubs. > > > Both sides brought street medics equipped with bandages and fluids for flushing eyes and skin afflicted with pepper spray. > > > This can be seen [here](https://youtu.be/67zCG-KPWfQ?t=4m55s), where the Alt-Right is marching with shields, helmets, and flags; in response, a fight breaks out between Antifa and the front line. Regrettably, who threw the first punch is obscured by the crowd. [At another point](https://youtu.be/67zCG-KPWfQ?t=6m54s), the Alt-right regroup, and are commanded back into action, shields and clubs used to batter the crowd. One of the counter protestors, [Jacob L. Smith](https://www.mediaite.com/online/one-of-the-men-arrested-in-charlottesville-was-a-counter-protestor-who-punched-a-female-reporter/), [punched](https://youtu.be/67zCG-KPWfQ?t=8m3s) a [Reporter Taylor Lorenz](http://www.newsleader.com/story/news/local/2017/08/14/reporter-punched-face-during-charlottesville-rally/565922001/) from The Hill for taping the events. A New York Times Reporter, Sheryl Gay Stolberg, [tweeted](https://twitter.com/SherylNYT/status/896575560650035200?ref_src=twsrc%5Etfw&ref_url=http%3A%2F%2Fwww.dailywire.com%2Fnews%2F19673%2Fny-times-reporter-admits-antifa-protesters-james-barrett%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_content%3D062316-news%26utm_campaign%3Dbenshapiro): > > The hard left seemed as hate-filled as alt-right. I saw club-wielding "antifa" beating white nationalists being led out of the park 2/2 > > > This lasted up until the backlash that she was "creating an equivalency." African American individual utilized an [improvised flamethrower](http://www.newyorker.com/culture/annals-of-appearances/an-image-of-revolutionary-fire-at-charlottesville?mbid=social_facebook_aud_dev_kw_paid-an-image-of-revolutionary-fire-at-charlottesville&kwp_0=496548&kwp_4=1784481&kwp_1=759637) against a large group of Alt-Right. His story, presented by the [Independent](http://www.independent.co.uk/news/world/americas/charlottesville-care-worker-neo-nazis-corey-long-flame-thrower-peaceful-protest-virginia-ku-klux-a7894161.html), sets the premise that he had attended the protest to heckle the Alt-Right, including claims that a gun was held to his head and a shot was fired at his feet. At a later point during the event, he was involved in an altercation where he used a spray can he found on the ground and a lighter in his pocket to hold off the crowd. This order of events (brandished firearm, discharged firearm, lunging with flag, and employment of improvised flame thrower), are disproved by a [video released](https://www.nytimes.com/2017/08/25/us/charlottesville-protest-police.html?mcubz=0) by the ACLU of Virginia. In this video, the order of events are depicted as: * Crowd is moving through * Spray starts from can directed towards faces of protestors * People walk away from the spray or cover their mouths * Spray is lit on fire, directed towards the protestors * Protestor A starts waving flag towards fire * Protestor B uses racial epithet, attempts to fire a shot: Gun Malfunction (expect no round chambered) * Protestor B manipulates slide, chambering round, fires shot into ground before Counter Protestor using improvised Flame thrower * Protestor B retreats. Quantity -------- The current dead - injured - missing values for the event are 3 - more than 36 - 0, as reported by [Charlottesville Officials](http://www.businessinsider.com/car-hits-counter-protesters-charlottesville-white-nationalist-rally-2017-8). This includes the tragic helicopter crash (2-0-0), the injuries from the vehicular murder (1-19-0), and individual altercations (0-more than 17-0). This does not account for people that were injured during individual altercations but did not seek medical aid, or associate their request for medical aid with the incident. Regrettably, there isn't a fullness of understanding for that total number of violent altercations. Self Defense ------------ It is possible that some of the violence that occurred during this protest was purely self defense. Virginia defines self defense, from charges of [Assault or Battery](http://www.livesaymyers.com/criminal-lawyers/assault-and-battery/), via common law and court decisions, as: > > Committing a battery with legal justification: hitting, pushing, scratching, etc. a person who placed you in “reasonable fear” of “imminent danger of bodily harm,” where your actions were “reasonably necessary to protect” yourself. An act that began as self-defense can cross the line into a separate crime of battery if you use excessive or unreasonable force in defending yourself. > > > From the same link, when considering that the police chief said many altercations between both groups were "mutually combative," all of those participants are wrong doers as described by SCOTUS case [Rowe V. United States](http://supreme.justia.com/cases/federal/us/164/546/). If an individual was to claim [Self Defense](http://www.livesaymyers.com/self-defense-assault-battery/) as an affirmative defense to charges, it is important that you either didn't instigate the altercation (fighting words, overt threats, etc.) or that you've made a good faith effort to abandon the fight. Domestic Terrorism ================== From the [Patriot Act, as understood by the ACLU](https://www.aclu.org/other/how-usa-patriot-act-redefines-domestic-terrorism), our definition is: > > A person engages in domestic terrorism if they do an act "dangerous to human life" that is a violation of the criminal laws of a state or the United States, if the act appears to be intended to: (i) intimidate or coerce a civilian population; (ii) influence the policy of a government by intimidation or coercion; or (iii) to affect the conduct of a government by mass destruction, assassination or kidnapping. Additionally, the acts have to occur primarily within the territorial jurisdiction of the United States and if they do not, may be regarded as international terrorism. > > > Driving a car through a crowd of people that were offering a counter protest to your activities fits this definition. Though it should be noted that the violence as speech from both sides, which lead to the Police force terminating the Unite the Right protest and calling for the groups to disperse, could also fit within this definition. Consider reporting from [Politico](http://www.politico.com/story/2017/09/01/antifa-charlottesville-violence-fbi-242235?lo=ap_c1) detailing their activities as "domestic terror violence." This is not a media term; it is the legal definition by which the events of Charlottesville should be judged. All sides aren't violent in a riot; Simplistically there were two sides at this fight, but that doesn't account for the idiots or peaceful folk that joined into the fight with out intentions to resort to violence. this allows for the possibility that: > > There were leftist protest who were intent on peaceably protesting the Alt-Right Antics. > > > There were some misguided idiots from the right who were there for "free speech" reasons. *Note: In today's climate, look who is standing next to you. If you're beside people that embrace white power, you're going to be associated with nazis.* > > > Who are the Nazis? ================== In the context of this answer, the Nazis are the violent extremes of the Unite the Right Protest. This includes those chanting Hail Victory, performing the colloquially recognized Nazi Salute, or openly displaying White Supremacy symbolism (white pride flags). This answer rejects the implication that *all of the right* are Nazis.
How about we let a relatively objective number speak? According to Governor McAuliffe, from multiple [interviews Monday](http://www.npr.org/2017/08/14/543358169/incident-in-charlottesville-will-make-us-stronger-gov-mcauliffe-says), not a single "alt-right" protestor ended up dead or hospitalized from the rally.\* He seemed quite proud of that. According to news sources, [1 person died and 19 were hospitalized](http://www.cbsnews.com/news/charlottesville-white-supremacist-protest-victims-heather-heyer-friends/) as a result of the violence at the rallies. That's of course not counting the two officers who died in a helicopter crash monitoring the protests. A wag would point out here that 19 (or one) divided by zero is infinity. But even without playing statistical games like that, its pretty clear from the numbers that nearly all (if not all) of the serious violence was being carried out by the alt-right. \* - This could **really** use independent confirmation.
58,226
In the first line of [this poem by Stefan George](https://www.textarchiv.com/stefan-george/von-einer-begegnung): > > Nun rufen lange schatten mildre gluten > > > What is happening in "mildre"? What does it mean? Is it a poetic way to write "milder"?
2020/04/19
[ "https://german.stackexchange.com/questions/58226", "https://german.stackexchange.com", "https://german.stackexchange.com/users/41235/" ]
> > Is it a poetic way to write "milder"? > > > Yes, it means *mildere* and is poetically shortcutted.
Leaving out an "e" from adjectives is a common way of keeping rhythm in German poetry, as the following proverbial wisdoms demonstrate: > > Auch wenn er keine Früchte kriegt - der **grünre** Baum hat doch gesiegt. > > > Versprich vom kurzen dir nicht viel, der **längre** Weg führt auch zum Ziel. > > > Ein Meister ist, wer **andern** ihre Fehler zeigt. Ein **größrer** ist, wer wissend schweigt. > > > And so on.
53,715,505
I created an Observable generating potentially infinite amount of data (e.g. a timer). This data is accessed through a subject, so multiple observers would receive the same values. How to stop the Observable generating new values? (without modifying the implementation of the Observable) ``` // custom Observable, to visualize internal behavior const timer$ = new rxjs.Observable(subscriber => { console.log("observable init"); var counter = 0; const intervalId = setInterval(() => { ++counter; console.log("observable %s",counter); subscriber.next(counter); }, 1000); return () => { console.log("observable teardown"); clearTimeout(intervalId); } }); // subscribe through a subject const subject$ = new rxjs.Subject(); timer$.subscribe(subject$); const subscription = subject$.subscribe(value => console.log("observer %s", value)); // cancel subscription setTimeout(() => { console.log("unsubscribe observer"); subscription.unsubscribe(); // TODO how to stop Observable generating new values? }, 3000); ``` jsfiddle: <https://jsfiddle.net/gy4tfd5w/>
2018/12/10
[ "https://Stackoverflow.com/questions/53715505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1977315/" ]
Fortunately, there is a dedicated and elegant way to solve this in RxJS. Your requirement is to have > > multiple observers [...] receive the same values > > > That's called a *multicast* observable and there are certain *operators* that are used to create one from an ordinary "cold" observable. For example, instead of creating an instance of `Subject` directly, you can just pipe the source observable to the `share` operator and it will create the `Subject` for you. The documentation of `share` reads: > > Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will unsubscribe from the source Observable. > > > The last sentence shows the subtle difference between `share` and `source$.subscribe(subject)`. With `share` a so-called `refCount` is kept that unsubscribes the `Subject` from its source automatically when there are no subscribers to it left. Applied to your code, it looks like this: ``` const timer$ = new rxjs.Observable(subscriber => {// your unchanged implementation}) .pipe( share() ); const subscription = timer$.subscribe(value => console.log("observer %s", value)); ``` Here is the full version with your example code: <https://jsfiddle.net/50q746ad/> By the way, `share` is not the only operator that performs multicasting. [There are great learning resources](https://www.learnrxjs.io/operators/multicasting/) that go much more in depth on that topic.
So after some PUNISHING research I've added my own npm library for this problem. `Improves previous answer by NOT having to add any extra convolution variables and ease of use.` * [StackBlitz](https://stackblitz.com/edit/typescript-dswrjc) * [Repo](https://github.com/dontboyle/rxjs-serial-subscription/wiki) * [NPM](https://www.npmjs.com/package/rxjs-serializable-subscription) [![enter image description here](https://camo.githubusercontent.com/485f787ac0a05a20cc7d4d0ce50642a8a7526081/68747470733a2f2f692e6962622e636f2f6b7157634862502f4e65772d4269746d61702d496d6167652e706e67)](https://camo.githubusercontent.com/485f787ac0a05a20cc7d4d0ce50642a8a7526081/68747470733a2f2f692e6962622e636f2f6b7157634862502f4e65772d4269746d61702d496d6167652e706e67)
53,715,505
I created an Observable generating potentially infinite amount of data (e.g. a timer). This data is accessed through a subject, so multiple observers would receive the same values. How to stop the Observable generating new values? (without modifying the implementation of the Observable) ``` // custom Observable, to visualize internal behavior const timer$ = new rxjs.Observable(subscriber => { console.log("observable init"); var counter = 0; const intervalId = setInterval(() => { ++counter; console.log("observable %s",counter); subscriber.next(counter); }, 1000); return () => { console.log("observable teardown"); clearTimeout(intervalId); } }); // subscribe through a subject const subject$ = new rxjs.Subject(); timer$.subscribe(subject$); const subscription = subject$.subscribe(value => console.log("observer %s", value)); // cancel subscription setTimeout(() => { console.log("unsubscribe observer"); subscription.unsubscribe(); // TODO how to stop Observable generating new values? }, 3000); ``` jsfiddle: <https://jsfiddle.net/gy4tfd5w/>
2018/12/10
[ "https://Stackoverflow.com/questions/53715505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1977315/" ]
Fortunately, there is a dedicated and elegant way to solve this in RxJS. Your requirement is to have > > multiple observers [...] receive the same values > > > That's called a *multicast* observable and there are certain *operators* that are used to create one from an ordinary "cold" observable. For example, instead of creating an instance of `Subject` directly, you can just pipe the source observable to the `share` operator and it will create the `Subject` for you. The documentation of `share` reads: > > Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will unsubscribe from the source Observable. > > > The last sentence shows the subtle difference between `share` and `source$.subscribe(subject)`. With `share` a so-called `refCount` is kept that unsubscribes the `Subject` from its source automatically when there are no subscribers to it left. Applied to your code, it looks like this: ``` const timer$ = new rxjs.Observable(subscriber => {// your unchanged implementation}) .pipe( share() ); const subscription = timer$.subscribe(value => console.log("observer %s", value)); ``` Here is the full version with your example code: <https://jsfiddle.net/50q746ad/> By the way, `share` is not the only operator that performs multicasting. [There are great learning resources](https://www.learnrxjs.io/operators/multicasting/) that go much more in depth on that topic.
Here's my solution to stop a crazy observable mid-flow. By using a signal `Subject` and the rxjs operator: `takeUntil` **Example** ```js const stopSignal$ = new Subject(); infinitelyGenerating$ .pipe(takeUntil(stopSignal$)) .subscribe(val => { if (val === 'bad') { stopSignal$.next() } }) ```
53,715,505
I created an Observable generating potentially infinite amount of data (e.g. a timer). This data is accessed through a subject, so multiple observers would receive the same values. How to stop the Observable generating new values? (without modifying the implementation of the Observable) ``` // custom Observable, to visualize internal behavior const timer$ = new rxjs.Observable(subscriber => { console.log("observable init"); var counter = 0; const intervalId = setInterval(() => { ++counter; console.log("observable %s",counter); subscriber.next(counter); }, 1000); return () => { console.log("observable teardown"); clearTimeout(intervalId); } }); // subscribe through a subject const subject$ = new rxjs.Subject(); timer$.subscribe(subject$); const subscription = subject$.subscribe(value => console.log("observer %s", value)); // cancel subscription setTimeout(() => { console.log("unsubscribe observer"); subscription.unsubscribe(); // TODO how to stop Observable generating new values? }, 3000); ``` jsfiddle: <https://jsfiddle.net/gy4tfd5w/>
2018/12/10
[ "https://Stackoverflow.com/questions/53715505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1977315/" ]
Here's my solution to stop a crazy observable mid-flow. By using a signal `Subject` and the rxjs operator: `takeUntil` **Example** ```js const stopSignal$ = new Subject(); infinitelyGenerating$ .pipe(takeUntil(stopSignal$)) .subscribe(val => { if (val === 'bad') { stopSignal$.next() } }) ```
So after some PUNISHING research I've added my own npm library for this problem. `Improves previous answer by NOT having to add any extra convolution variables and ease of use.` * [StackBlitz](https://stackblitz.com/edit/typescript-dswrjc) * [Repo](https://github.com/dontboyle/rxjs-serial-subscription/wiki) * [NPM](https://www.npmjs.com/package/rxjs-serializable-subscription) [![enter image description here](https://camo.githubusercontent.com/485f787ac0a05a20cc7d4d0ce50642a8a7526081/68747470733a2f2f692e6962622e636f2f6b7157634862502f4e65772d4269746d61702d496d6167652e706e67)](https://camo.githubusercontent.com/485f787ac0a05a20cc7d4d0ce50642a8a7526081/68747470733a2f2f692e6962622e636f2f6b7157634862502f4e65772d4269746d61702d496d6167652e706e67)
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
This is of course not a bug. It is the range modifier that can precede commands, in this case it means the visually highlighted range. Type ``` :h cmdline-ranges ``` to learn more about ranges.
they're normal indication of a range.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
You have a visual range selected, and when you enter `:` while that is the case, then the *selected range* specifier `'<,'>` is automatically added to indicate that the command will only be applied to the selection.
they're normal indication of a range.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
In vi[m], you can apply `:` commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. The range is denoted as `start,end`. For example, do delete the current line, you can do: ``` :d ``` To delete three lines in the range (current-1) to (current+1): ``` :-1,+1d ``` In *vim*, marks `<` and `>` are used to denote the current selection (or the last selection if nothing is selected). So, when you type a `:` in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the `:`. You just type your command and the results apply only to the selection. (Well, the range defined by lines in the selection, to be precise.) That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing `'<` and `'>` respectively. Replace `'` with ``` (backtick) to the beginning/end of the selection.
they're normal indication of a range.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
You have a visual range selected, and when you enter `:` while that is the case, then the *selected range* specifier `'<,'>` is automatically added to indicate that the command will only be applied to the selection.
This is of course not a bug. It is the range modifier that can precede commands, in this case it means the visually highlighted range. Type ``` :h cmdline-ranges ``` to learn more about ranges.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
In vi[m], you can apply `:` commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. The range is denoted as `start,end`. For example, do delete the current line, you can do: ``` :d ``` To delete three lines in the range (current-1) to (current+1): ``` :-1,+1d ``` In *vim*, marks `<` and `>` are used to denote the current selection (or the last selection if nothing is selected). So, when you type a `:` in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the `:`. You just type your command and the results apply only to the selection. (Well, the range defined by lines in the selection, to be precise.) That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing `'<` and `'>` respectively. Replace `'` with ``` (backtick) to the beginning/end of the selection.
This is of course not a bug. It is the range modifier that can precede commands, in this case it means the visually highlighted range. Type ``` :h cmdline-ranges ``` to learn more about ranges.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
This is of course not a bug. It is the range modifier that can precede commands, in this case it means the visually highlighted range. Type ``` :h cmdline-ranges ``` to learn more about ranges.
`'<,'>` is your visually selected area. Think about it, its easy to represent ranges if you know numbers, but for a visually selected text the only way to represent them (write/type it down) would be to use specialized symbols, and in this case `'<,'>` What more, you can do commands on the visually selected area the same way you'd do commands over a range of line numbers `1,200 s/old/new/c` `'<,'> s/old/new/c`
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
You have a visual range selected, and when you enter `:` while that is the case, then the *selected range* specifier `'<,'>` is automatically added to indicate that the command will only be applied to the selection.
In vi[m], you can apply `:` commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. The range is denoted as `start,end`. For example, do delete the current line, you can do: ``` :d ``` To delete three lines in the range (current-1) to (current+1): ``` :-1,+1d ``` In *vim*, marks `<` and `>` are used to denote the current selection (or the last selection if nothing is selected). So, when you type a `:` in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the `:`. You just type your command and the results apply only to the selection. (Well, the range defined by lines in the selection, to be precise.) That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing `'<` and `'>` respectively. Replace `'` with ``` (backtick) to the beginning/end of the selection.
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
You have a visual range selected, and when you enter `:` while that is the case, then the *selected range* specifier `'<,'>` is automatically added to indicate that the command will only be applied to the selection.
`'<,'>` is your visually selected area. Think about it, its easy to represent ranges if you know numbers, but for a visually selected text the only way to represent them (write/type it down) would be to use specialized symbols, and in this case `'<,'>` What more, you can do commands on the visually selected area the same way you'd do commands over a range of line numbers `1,200 s/old/new/c` `'<,'> s/old/new/c`
2,056,615
I have a dropdownlist like this ``` <asp:dropdownlist runat="server" autopostback="true" onselecteditemindexchanged="fire_event" ID="DDL"/> ``` and on codebehind i m doing this ``` page_load : if(!page.postback)I m binding data into dropdownlist fire_event: I am redirecting page to itemselected value. ``` So I am able to do most of the part everything is working perfectly except.. when i select item in dropdown it redirects me to the page I wanted..but when i click back it remains at the same item selected value .I want it to be like that it loads again when i click back for e.g. if my dropdown is like state `A` and other items ``` A B C D ``` when I select `D` it takes me to page `D` and when i click back it is at state `D` i want it to show `A` instead of `D`
2010/01/13
[ "https://Stackoverflow.com/questions/2056615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/237112/" ]
In vi[m], you can apply `:` commands (ex-commands) on the current line (default), or any other line, or more generally, a range of lines. The range is denoted as `start,end`. For example, do delete the current line, you can do: ``` :d ``` To delete three lines in the range (current-1) to (current+1): ``` :-1,+1d ``` In *vim*, marks `<` and `>` are used to denote the current selection (or the last selection if nothing is selected). So, when you type a `:` in visual mode, vim is smart enough to realize that you might want to apply the command only to the selected region, so gives you the range after the `:`. You just type your command and the results apply only to the selection. (Well, the range defined by lines in the selection, to be precise.) That means that you can actually move to the lines containing the beginning and the end of the last selected region by typing `'<` and `'>` respectively. Replace `'` with ``` (backtick) to the beginning/end of the selection.
`'<,'>` is your visually selected area. Think about it, its easy to represent ranges if you know numbers, but for a visually selected text the only way to represent them (write/type it down) would be to use specialized symbols, and in this case `'<,'>` What more, you can do commands on the visually selected area the same way you'd do commands over a range of line numbers `1,200 s/old/new/c` `'<,'> s/old/new/c`
27,414,810
My colleage says static is good when you perform fixed stuff that doesn't required any extends, but one day we need to add feature on top of his code. Heck we have to modify the ori code because he used tons of static stuff and it's not flexible for us to continue. ``` class test { public static function test1() { echo 'hi'; } } test::test1(); ``` Why should one should use static function? When to use it and not to use static function?
2014/12/11
[ "https://Stackoverflow.com/questions/27414810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4327335/" ]
You use static when the function doesn't depend on a specific object that the method is being applied to. How that applies to your application depends on its design. For instance, if you have a class for dealing with dates and times, and it contains a function to return the current timestamp, it doesn't need to be applied to a specific date object -- it's the same for any date. So it could be a static function. Static functions may be necessary if you need to run some functions before creating any instances of the class. If you use the Factory pattern, you will use a method to create instances in the first place. This will necessarily be a static method.
As a general rule of thumb it is best to stay away from static code whenever possible. When you start using static calls you are *tight-coupling* the class into your code. This makes it difficult to test your code later on when you want to swap out the static class for a mock class. For most cases, it is best to use dependency injection instead. That said, like sugar and salt, static code has its place and if you are careful and utilize it correctly you can have applications that work well with your static code. For example, the singleton pattern depends on a static method to attain the reference to the singleton itself. Static methods work nice for basic utility functions that do not need to depend on any class state. In the end, it is best to stay away from them. Some folks call them evil (they are not), but if you are using them, at least take the time to explore *why* you are using them and if the design of a static class is better than a concrete one for your particular use case.
27,414,810
My colleage says static is good when you perform fixed stuff that doesn't required any extends, but one day we need to add feature on top of his code. Heck we have to modify the ori code because he used tons of static stuff and it's not flexible for us to continue. ``` class test { public static function test1() { echo 'hi'; } } test::test1(); ``` Why should one should use static function? When to use it and not to use static function?
2014/12/11
[ "https://Stackoverflow.com/questions/27414810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4327335/" ]
You use static when the function doesn't depend on a specific object that the method is being applied to. How that applies to your application depends on its design. For instance, if you have a class for dealing with dates and times, and it contains a function to return the current timestamp, it doesn't need to be applied to a specific date object -- it's the same for any date. So it could be a static function. Static functions may be necessary if you need to run some functions before creating any instances of the class. If you use the Factory pattern, you will use a method to create instances in the first place. This will necessarily be a static method.
You can use static function if you need a function without calling the Class constructor before. For example, i have a class like this : ``` class Animal { ............. ......... private function name() { // This will print name of Animal that you assign through $this echo $this->$name; } } Animal->name(); ``` at another case, you want to implement a function to your class that doesn't require $this for that. And the second : ``` class Animal { ............. ......... public static function splitName($name) { // In this case your source is assigned by parameter, not by $this echo explode("-",$name); } } Animal::splitName(); ``` If you are beginner, to easy remember is 'If you use static function, data source come from param. and then for Private function the data came from $this' ... got it ? Ask me more by comment, james
2,066,741
In some discussions of [metric tensors $g : TM\_p \times TM\_p \rightarrow \mathbb R$](https://en.wikipedia.org/wiki/Metric_tensor) (and even of pseudo-metric tensors, for instance in [this answer](https://physics.stackexchange.com/questions/299431)), and of the corresponding [first fundamental forms ${\rm d}s^2$](https://en.wikipedia.org/wiki/Metric_tensor#Arclength_and_the_line_element), these (mathematical) objects are referred to as "metric". Is this serious and correct terminology? Is it really true that metric tensors, or (even) pseudo-metric tensors, and/or the corresponding first fundamental forms are [metrics (in the specific well-known sense)](https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition), by which accordingly $g : X \times X \rightarrow \mathbb R$ for some suitable set $X$, such that $\forall x, y, z \in X$: * [$g[~x, y~] \neq 0 ~ ~\Leftrightarrow ~ ~ x \not\equiv y ~$ (distinguishability of distinct elements)](https://en.wikipedia.org/wiki/Distinction), * [$g[~x, y~] = g[~y, x~]$ (symmetry)](https://en.wikipedia.org/wiki/Symmetric_function), * [$g[~x, z~] \le g[~x, y~] + g[~y, z~]$ (subadditivity; triangle inequality)](https://en.wikipedia.org/wiki/Triangle_inequality) ?
2016/12/19
[ "https://math.stackexchange.com/questions/2066741", "https://math.stackexchange.com", "https://math.stackexchange.com/users/277973/" ]
From the metric we get a curve length, if the manifold is connected we can define a distance function as the infimum of curve lengths between two points (this exists if the metric is positive definite). It is easily checked that this defines a metric in the usual sense. A Lorentzian metric does not define a metric in the usual sense, as points may be connected by a zero length curve.
It works if the metric has only positive eigenvalues. It is not the case, for example, for Minkowski space where $g(V,V)=0$ for some vectors (light-like ones).
2,066,741
In some discussions of [metric tensors $g : TM\_p \times TM\_p \rightarrow \mathbb R$](https://en.wikipedia.org/wiki/Metric_tensor) (and even of pseudo-metric tensors, for instance in [this answer](https://physics.stackexchange.com/questions/299431)), and of the corresponding [first fundamental forms ${\rm d}s^2$](https://en.wikipedia.org/wiki/Metric_tensor#Arclength_and_the_line_element), these (mathematical) objects are referred to as "metric". Is this serious and correct terminology? Is it really true that metric tensors, or (even) pseudo-metric tensors, and/or the corresponding first fundamental forms are [metrics (in the specific well-known sense)](https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition), by which accordingly $g : X \times X \rightarrow \mathbb R$ for some suitable set $X$, such that $\forall x, y, z \in X$: * [$g[~x, y~] \neq 0 ~ ~\Leftrightarrow ~ ~ x \not\equiv y ~$ (distinguishability of distinct elements)](https://en.wikipedia.org/wiki/Distinction), * [$g[~x, y~] = g[~y, x~]$ (symmetry)](https://en.wikipedia.org/wiki/Symmetric_function), * [$g[~x, z~] \le g[~x, y~] + g[~y, z~]$ (subadditivity; triangle inequality)](https://en.wikipedia.org/wiki/Triangle_inequality) ?
2016/12/19
[ "https://math.stackexchange.com/questions/2066741", "https://math.stackexchange.com", "https://math.stackexchange.com/users/277973/" ]
Yes, it is true, but note that the metric tensor $g$ *defines* the distance function on $TM$ and hence a norm, it is not itself the distance function. In particular, for $TM$ we can define $$d(\vec{x}, \vec{y}) \equiv \sqrt{g(\vec{x} - \vec{y}, \vec{x} - \vec{y})} \quad\forall \vec{x}, \vec{y} \in TM$$ It's relatively easy to show that if $g$ is a metric (as opposed to a pseudometric) this definition of $d$ works as you would expect. Note that I am answering about the relationship between $g$ and $d$ on $TM$: $g$ also makes $M$ a metric space, but that's a slightly different argumentt.
It works if the metric has only positive eigenvalues. It is not the case, for example, for Minkowski space where $g(V,V)=0$ for some vectors (light-like ones).
2,066,741
In some discussions of [metric tensors $g : TM\_p \times TM\_p \rightarrow \mathbb R$](https://en.wikipedia.org/wiki/Metric_tensor) (and even of pseudo-metric tensors, for instance in [this answer](https://physics.stackexchange.com/questions/299431)), and of the corresponding [first fundamental forms ${\rm d}s^2$](https://en.wikipedia.org/wiki/Metric_tensor#Arclength_and_the_line_element), these (mathematical) objects are referred to as "metric". Is this serious and correct terminology? Is it really true that metric tensors, or (even) pseudo-metric tensors, and/or the corresponding first fundamental forms are [metrics (in the specific well-known sense)](https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition), by which accordingly $g : X \times X \rightarrow \mathbb R$ for some suitable set $X$, such that $\forall x, y, z \in X$: * [$g[~x, y~] \neq 0 ~ ~\Leftrightarrow ~ ~ x \not\equiv y ~$ (distinguishability of distinct elements)](https://en.wikipedia.org/wiki/Distinction), * [$g[~x, y~] = g[~y, x~]$ (symmetry)](https://en.wikipedia.org/wiki/Symmetric_function), * [$g[~x, z~] \le g[~x, y~] + g[~y, z~]$ (subadditivity; triangle inequality)](https://en.wikipedia.org/wiki/Triangle_inequality) ?
2016/12/19
[ "https://math.stackexchange.com/questions/2066741", "https://math.stackexchange.com", "https://math.stackexchange.com/users/277973/" ]
Yes, it is true, but note that the metric tensor $g$ *defines* the distance function on $TM$ and hence a norm, it is not itself the distance function. In particular, for $TM$ we can define $$d(\vec{x}, \vec{y}) \equiv \sqrt{g(\vec{x} - \vec{y}, \vec{x} - \vec{y})} \quad\forall \vec{x}, \vec{y} \in TM$$ It's relatively easy to show that if $g$ is a metric (as opposed to a pseudometric) this definition of $d$ works as you would expect. Note that I am answering about the relationship between $g$ and $d$ on $TM$: $g$ also makes $M$ a metric space, but that's a slightly different argumentt.
From the metric we get a curve length, if the manifold is connected we can define a distance function as the infimum of curve lengths between two points (this exists if the metric is positive definite). It is easily checked that this defines a metric in the usual sense. A Lorentzian metric does not define a metric in the usual sense, as points may be connected by a zero length curve.
34,811,128
i want to use switch function inside tabview cellForRowAtIndexPath to change the content of table the scenario : the flag variable should select which the case and return it's content. the error : i have to use return cell out side the switch function if i use it still give me error. ``` switch (flag){ case 0 : let cell:mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function else { print(error) } } return cell break case 1 : let cell:followingCell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion else { print(error) } } return cell break case 2 : //funtion break default: break } //*HERE i have to use return cell but if i use it will give me error in somehow * } ```
2016/01/15
[ "https://Stackoverflow.com/questions/34811128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5343449/" ]
Try this in your `cellForRow` method ``` switch (flag){ case 0 : let cell:mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function else { print(error) } } return cell break case 1 : let cell:followingCell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion else { print(error) } } return cell break } } ``` Hope it helps.
Your `cellForRowAtIndexPath` has to return a `UITableViewCell` object or subclass of it in every possible scenario. Therefore you have to return a `UITableViewCell()` in your default case to get rid of your error.
34,811,128
i want to use switch function inside tabview cellForRowAtIndexPath to change the content of table the scenario : the flag variable should select which the case and return it's content. the error : i have to use return cell out side the switch function if i use it still give me error. ``` switch (flag){ case 0 : let cell:mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function else { print(error) } } return cell break case 1 : let cell:followingCell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion else { print(error) } } return cell break case 2 : //funtion break default: break } //*HERE i have to use return cell but if i use it will give me error in somehow * } ```
2016/01/15
[ "https://Stackoverflow.com/questions/34811128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5343449/" ]
Your `cellForRowAtIndexPath` has to return a `UITableViewCell` object or subclass of it in every possible scenario. Therefore you have to return a `UITableViewCell()` in your default case to get rid of your error.
First you need to declare the `UITableViewCell` object in global. ``` func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell switch (flag) { case 0 : { cell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function if() { }else { print(error) } return cell } break case 1 : { cell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion if() { } else { print(error) } return cell } break default: break } return cell } ```
34,811,128
i want to use switch function inside tabview cellForRowAtIndexPath to change the content of table the scenario : the flag variable should select which the case and return it's content. the error : i have to use return cell out side the switch function if i use it still give me error. ``` switch (flag){ case 0 : let cell:mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function else { print(error) } } return cell break case 1 : let cell:followingCell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion else { print(error) } } return cell break case 2 : //funtion break default: break } //*HERE i have to use return cell but if i use it will give me error in somehow * } ```
2016/01/15
[ "https://Stackoverflow.com/questions/34811128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5343449/" ]
Try this in your `cellForRow` method ``` switch (flag){ case 0 : let cell:mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function else { print(error) } } return cell break case 1 : let cell:followingCell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion else { print(error) } } return cell break } } ``` Hope it helps.
First you need to declare the `UITableViewCell` object in global. ``` func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell switch (flag) { case 0 : { cell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell // User Name on cells cell.usernameLabel.text = creator[indexPath.row] //function if() { }else { print(error) } return cell } break case 1 : { cell = tableView.dequeueReusableCellWithIdentifier("followingCell")as! followingCell // User Name on cells cell.followingNameLabel.text = creator[indexPath.row] //ffuntion if() { } else { print(error) } return cell } break default: break } return cell } ```
49,662,374
I'm running into a typing error, specifically when I spread over props as I pass it into a React Component. ``` type FooLevel = 1 | 2 | 3 interface FooProps { fooLevel: FooLevel; } // Typing for a SFC const Foo = ({ fooLevel }: FooProps) => { return ( <div> <span>Your foo level {fooLevel}</span> </div> ) } // Foo invocation: const props = { fooLevel: 1 } <Foo fooLevel={1} /> // this works <Foo {...props} /> // error - Type 'number' is not assignable to type 'FooLevel' ``` It looks like it's having trouble connecting a `number` to a `FooLevel`. Is this by design? Is there a way to circumvent this issue?
2018/04/05
[ "https://Stackoverflow.com/questions/49662374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5209122/" ]
Try adding `overflow: auto;` to the `.main` div ``` .container .innerContainer .main { background-color: #A3845D; flex-grow: 1; display: flex; overflow: auto; /*<< added */ } ``` Works fine on my version of FF (59.0.2) can't check in IE currently.
**NOTICE** - *Fecosos gave the right answer and beat me to it by a long time. I'll leave up my code as it strips out a lot of the unnecessary stuff.* --- Apologies for butchering your code but this seems to work in FF and Chrome. No idea about IE. (I recall Safari giving me the most problems but I forget if it was with this specific issue.) Note - I copied this code from an app where I was having a similar problem and I never figured out why the problem existed, I recall just trial and erroring different things until I got something that worked. **pen** <https://codepen.io/nooble/pen/GxXyzb> **code** ```js var rightPanel = document.getElementById("rightPanel"); for(var loop = 0; loop < 50; loop++) { var contentNode = document.createElement("div"); contentNode.className = "content"; contentNode.innerText = "Content"; rightPanel.appendChild(contentNode); } ``` ```css * { margin: 0; padding: 0; text-align: center; font-family: "Roboto"; } body { height: 100vh; } .container { display: flex; flex-direction: column; height: 100%; } .main { display: flex; overflow-y: auto; /* this is important */ } .left { flex: 1; max-width: 100px; } .right { flex: 2; width: 100%; overflow-y: auto; /* this is important */ } /* unnecessary styling stuff below */ body { background-color: grey; } .header { background-color: red; } .navigator { background-color: #5E6074; } .main { background-color: #A3845D; } .left { background-color: #808080; } .right { background-color: #78AB86; } .content { background-color: #406C98; } .footer { background-color: green; } ``` ```html <div class="container"> <div class="header">Header</div> <div class="navigator">Navigator</div> <div class="main"> <div class="left">Left</div> <div class="right" id="rightPanel"> </div> </div> <div class="footer">Footer</div> </div> ```
44,138,815
I am trying to update the number stored in a field,this is the code I have used ``` Select * From MEDICATION UPDATE medication set seq_number = 2 where pet_id = "PO145" AND vet_id = "V01" AND MEDICINE ='Soothing Cream'; ``` The error returned states > > ORA-00933: SQL command not properly ended > > >
2017/05/23
[ "https://Stackoverflow.com/questions/44138815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7785347/" ]
As @Tim mentioned, select and update should be different. So run them individually. Also the strings should be enclosed in `single quotes`, not double. Although this is not the reason for error, but it will not work for you with `double quotes`. Double quotes should be used for object/column names. Also it is a good practice to run the `where` clause used in `update` or `delete`, with `select` first, as it will let you see what rows are returned, which will be updated or deleted. ``` UPDATE medication set seq_number = 2 where pet_id = 'PO145' AND vet_id = 'V01' AND MEDICINE ='Soothing Cream'; ```
It looks like you're trying to do a `SELECT` and an `UPDATE` at the same time. You can't do that. For the update, just use the latter part of your query by itself: ``` UPDATE medication SET seq_number = 2 WHERE pet_id = "PO145" AND vet_id = "V01" AND MEDICINE = 'Soothing Cream'; ``` After the update, if you want to do a `SELECT * FROM medication` then this should be no problem.
3,466,667
It's an IBDP question. When I try to solve it, I end up with a fraction with many variables. I was thinking maybe I should rationalize the fraction...
2019/12/07
[ "https://math.stackexchange.com/questions/3466667", "https://math.stackexchange.com", "https://math.stackexchange.com/users/731254/" ]
> > How many bit strings of length $15$ have exactly five 0's? > > > Your answer is correct. Choose five of the $15$ positions in the bit string for the zeros, then fill each of the remaining ten positions in the bit string with ones. This can be done in $$\binom{15}{5} = \frac{15!}{5!10!} = \frac{15 \cdot 14 \cdot 13 \cdot 12 \cdot 11 \cdot 10!}{5!10!} = \frac{15 \cdot 14 \cdot 13 \cdot 12 \cdot 11}{5!} = 3003$$ ways. > > How many bit strings of length $15$ have at least ten 1's? > > > A bit string of length $15$ that has at least ten 1's must have exactly ten 1's or exactly eleven 1's or exactly twelve 1's or exactly thirteen 1's or exactly fourteen 1's or exactly fifteen 1's. In each of these six cases, choose the positions for the 1's, then fill each of the remaining positions with zeros. Add up. > > $$\binom{15}{10} + \binom{15}{11} + \binom{15}{12} + \binom{15}{13} + \binom{15}{14} + \binom{15}{15} = 3003 + 1365 + 455 + 105 + 15 + 1 = 4944$$ > > > The third question is similar to the second one. Just note that if there are more ones than zeros, then there must be at least eight ones.
Isn't this just binomial coefficient stuff? Consider an length-$n$ bit string, and suppose it starts out all zeroes, and you want to put exactly $k\le n$ ones in it. Then there are $n$ positions in which you can put the first one, $n-1$ remaining positions for the second one, etc. So in the end there are $n\times(n-1)\times\ldots\times(n-k+1)=\frac{n!}{(n-k)!}$ ways. But that includes "duplicates" when you just change the order. That is, *e.g.*, place the first $1$ in position $5$ and the second $1$ in position $7$, or *vice versa*. And that's just the number of permutations of $k$ things, or $k!$. So divide by that to get the ususal binomial coefficient $\frac{n!}{k!(n-k)!}=\left(n\atop k\right)$. So that would be for >>exactly<< $k$ ones in a length-$n$ bit string (or conversely $k$ zeroes, by similar reasoning). For, say $k$-or-less, just add up all the corresponding binomial coefficients $\displaystyle\sum^k\_{i=0}\left(n\atop i\right)$. And note that $\displaystyle\sum^n\_{i=0}\left(n\atop i\right)=2^n$, exactly the number of different binary strings of length $n$, as expected.
3,466,667
It's an IBDP question. When I try to solve it, I end up with a fraction with many variables. I was thinking maybe I should rationalize the fraction...
2019/12/07
[ "https://math.stackexchange.com/questions/3466667", "https://math.stackexchange.com", "https://math.stackexchange.com/users/731254/" ]
For Question 3: There are $2^{15}$ bitstrings of length $15$. None of them has equally many zeros and ones. By symmetry exactly half of them, i.e., $16\,384$, have more ones than zeros.
Isn't this just binomial coefficient stuff? Consider an length-$n$ bit string, and suppose it starts out all zeroes, and you want to put exactly $k\le n$ ones in it. Then there are $n$ positions in which you can put the first one, $n-1$ remaining positions for the second one, etc. So in the end there are $n\times(n-1)\times\ldots\times(n-k+1)=\frac{n!}{(n-k)!}$ ways. But that includes "duplicates" when you just change the order. That is, *e.g.*, place the first $1$ in position $5$ and the second $1$ in position $7$, or *vice versa*. And that's just the number of permutations of $k$ things, or $k!$. So divide by that to get the ususal binomial coefficient $\frac{n!}{k!(n-k)!}=\left(n\atop k\right)$. So that would be for >>exactly<< $k$ ones in a length-$n$ bit string (or conversely $k$ zeroes, by similar reasoning). For, say $k$-or-less, just add up all the corresponding binomial coefficients $\displaystyle\sum^k\_{i=0}\left(n\atop i\right)$. And note that $\displaystyle\sum^n\_{i=0}\left(n\atop i\right)=2^n$, exactly the number of different binary strings of length $n$, as expected.
3,466,667
It's an IBDP question. When I try to solve it, I end up with a fraction with many variables. I was thinking maybe I should rationalize the fraction...
2019/12/07
[ "https://math.stackexchange.com/questions/3466667", "https://math.stackexchange.com", "https://math.stackexchange.com/users/731254/" ]
> > How many bit strings of length $15$ have exactly five 0's? > > > Your answer is correct. Choose five of the $15$ positions in the bit string for the zeros, then fill each of the remaining ten positions in the bit string with ones. This can be done in $$\binom{15}{5} = \frac{15!}{5!10!} = \frac{15 \cdot 14 \cdot 13 \cdot 12 \cdot 11 \cdot 10!}{5!10!} = \frac{15 \cdot 14 \cdot 13 \cdot 12 \cdot 11}{5!} = 3003$$ ways. > > How many bit strings of length $15$ have at least ten 1's? > > > A bit string of length $15$ that has at least ten 1's must have exactly ten 1's or exactly eleven 1's or exactly twelve 1's or exactly thirteen 1's or exactly fourteen 1's or exactly fifteen 1's. In each of these six cases, choose the positions for the 1's, then fill each of the remaining positions with zeros. Add up. > > $$\binom{15}{10} + \binom{15}{11} + \binom{15}{12} + \binom{15}{13} + \binom{15}{14} + \binom{15}{15} = 3003 + 1365 + 455 + 105 + 15 + 1 = 4944$$ > > > The third question is similar to the second one. Just note that if there are more ones than zeros, then there must be at least eight ones.
Your result is correct. The first thing that came to my mind was that a bitstring of length $15$ with $5$ zeros is the same as the bitstrings having a hamming weight of $10$. I wrote a short program that bruteforces all $2^{15}$ bitstrings, a counter and outputs the valid strings where hamming weight $=10$: ``` #define HammingWeight(a) __popcnt(a) std::bitset<15> bin15; int countInstances = 0, leastTen = 0, moreOnes = 0; FILE *fp = fopen("bitstrings.txt", "wb"); fprintf(fp, "\n"); for (int i = 0; i < 32768; i++) { if (HammingWeight(i) == 10) { bin15 = i; fprintf(fp, "%s\n", bin15.to_string().c_str()); countInstances++; } if (HammingWeight(i) >= 10) leastTen++; if (HammingWeight(i) >= (15 - HammingWeight(i))) moreOnes++; } fprintf(fp, "\nNumber of instances = %i\n", countInstances); fprintf(fp, "Least ten ones = %i\n", leastTen); fprintf(fp, "More ones than zeros = %i\n", moreOnes); fclose(fp); ``` Number of instances = $3003$ Least ten ones = $4944$ More ones than zeros = $16384$
3,466,667
It's an IBDP question. When I try to solve it, I end up with a fraction with many variables. I was thinking maybe I should rationalize the fraction...
2019/12/07
[ "https://math.stackexchange.com/questions/3466667", "https://math.stackexchange.com", "https://math.stackexchange.com/users/731254/" ]
For Question 3: There are $2^{15}$ bitstrings of length $15$. None of them has equally many zeros and ones. By symmetry exactly half of them, i.e., $16\,384$, have more ones than zeros.
Your result is correct. The first thing that came to my mind was that a bitstring of length $15$ with $5$ zeros is the same as the bitstrings having a hamming weight of $10$. I wrote a short program that bruteforces all $2^{15}$ bitstrings, a counter and outputs the valid strings where hamming weight $=10$: ``` #define HammingWeight(a) __popcnt(a) std::bitset<15> bin15; int countInstances = 0, leastTen = 0, moreOnes = 0; FILE *fp = fopen("bitstrings.txt", "wb"); fprintf(fp, "\n"); for (int i = 0; i < 32768; i++) { if (HammingWeight(i) == 10) { bin15 = i; fprintf(fp, "%s\n", bin15.to_string().c_str()); countInstances++; } if (HammingWeight(i) >= 10) leastTen++; if (HammingWeight(i) >= (15 - HammingWeight(i))) moreOnes++; } fprintf(fp, "\nNumber of instances = %i\n", countInstances); fprintf(fp, "Least ten ones = %i\n", leastTen); fprintf(fp, "More ones than zeros = %i\n", moreOnes); fclose(fp); ``` Number of instances = $3003$ Least ten ones = $4944$ More ones than zeros = $16384$
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You are very close to the correct answer. Add the negative numbers to the margin property: ``` #popup-button { position: absolute; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; margin-left: -35px; margin-top: -35px; } ```
You can manipulate with negative margin. This solution is cross-browser and is used often, but it is kind of "hacky": ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; margin-left: -35px; margin-top: -35px; opacity: 0.7; cursor: wait; } ``` Also, you can use CSS3 `calc()` function. It is a better approach, but it is not supported by all browsers ([calc() browser support](http://caniuse.com/#feat=calc)): ``` #popup-button { position: fixed; z-index: 9999; top: calc(50% - 35px); left: calc(50% - 35px); opacity: 0.7; cursor: wait; } ``` One more thing I need to mention. You can center anything in a container using `display: flex` with `align-items` and `justify-content` CSS3 properties ([flex browser suppport](http://caniuse.com/#feat=flexbox)). Note that it affects the arrangment and behavior of all child elements. ```css html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .full-page-container { display: flex; height: 100%; width: 100%; align-items: center; justify-content: center; } button { height: 64px; width: 64px; border: 3px solid gray; border-radius: 50%; } ``` ```html <div class="full-page-container"> <button>Hello World!</button> </div> ```
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You can manipulate with negative margin. This solution is cross-browser and is used often, but it is kind of "hacky": ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; margin-left: -35px; margin-top: -35px; opacity: 0.7; cursor: wait; } ``` Also, you can use CSS3 `calc()` function. It is a better approach, but it is not supported by all browsers ([calc() browser support](http://caniuse.com/#feat=calc)): ``` #popup-button { position: fixed; z-index: 9999; top: calc(50% - 35px); left: calc(50% - 35px); opacity: 0.7; cursor: wait; } ``` One more thing I need to mention. You can center anything in a container using `display: flex` with `align-items` and `justify-content` CSS3 properties ([flex browser suppport](http://caniuse.com/#feat=flexbox)). Note that it affects the arrangment and behavior of all child elements. ```css html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .full-page-container { display: flex; height: 100%; width: 100%; align-items: center; justify-content: center; } button { height: 64px; width: 64px; border: 3px solid gray; border-radius: 50%; } ``` ```html <div class="full-page-container"> <button>Hello World!</button> </div> ```
Maybe it would work with window height and width properties? Try `top: 100vh - 35px`
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You can manipulate with negative margin. This solution is cross-browser and is used often, but it is kind of "hacky": ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; margin-left: -35px; margin-top: -35px; opacity: 0.7; cursor: wait; } ``` Also, you can use CSS3 `calc()` function. It is a better approach, but it is not supported by all browsers ([calc() browser support](http://caniuse.com/#feat=calc)): ``` #popup-button { position: fixed; z-index: 9999; top: calc(50% - 35px); left: calc(50% - 35px); opacity: 0.7; cursor: wait; } ``` One more thing I need to mention. You can center anything in a container using `display: flex` with `align-items` and `justify-content` CSS3 properties ([flex browser suppport](http://caniuse.com/#feat=flexbox)). Note that it affects the arrangment and behavior of all child elements. ```css html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .full-page-container { display: flex; height: 100%; width: 100%; align-items: center; justify-content: center; } button { height: 64px; width: 64px; border: 3px solid gray; border-radius: 50%; } ``` ```html <div class="full-page-container"> <button>Hello World!</button> </div> ```
I agree with Adrian's answer. Using CSS3: ``` transform: translate(-50%, -50%); ``` Along with: ``` top: 50%; left: 50%; ``` Is a better solution as it's responsive, no matter the height or width of the parent you won't have to recalculate like some of the other solutions. Also don't forget to vendor prefix *transform* for various older versions of browsers, If you're using SASS I'd recommend this handy little [mixin](https://css-tricks.com/snippets/sass/mixin-prefix-properties/) by CSS Tricks.
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You are very close to the correct answer. Add the negative numbers to the margin property: ``` #popup-button { position: absolute; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; margin-left: -35px; margin-top: -35px; } ```
Maybe it would work with window height and width properties? Try `top: 100vh - 35px`
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You are very close to the correct answer. Add the negative numbers to the margin property: ``` #popup-button { position: absolute; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; margin-left: -35px; margin-top: -35px; } ```
I think it can be done without negative margins: ``` .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` Example: ```css .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: red; width: 10px; height: 10px; } ``` ```html <div class="centered"> </div> ```
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
You are very close to the correct answer. Add the negative numbers to the margin property: ``` #popup-button { position: absolute; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; margin-left: -35px; margin-top: -35px; } ```
I agree with Adrian's answer. Using CSS3: ``` transform: translate(-50%, -50%); ``` Along with: ``` top: 50%; left: 50%; ``` Is a better solution as it's responsive, no matter the height or width of the parent you won't have to recalculate like some of the other solutions. Also don't forget to vendor prefix *transform* for various older versions of browsers, If you're using SASS I'd recommend this handy little [mixin](https://css-tricks.com/snippets/sass/mixin-prefix-properties/) by CSS Tricks.
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
I think it can be done without negative margins: ``` .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` Example: ```css .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: red; width: 10px; height: 10px; } ``` ```html <div class="centered"> </div> ```
Maybe it would work with window height and width properties? Try `top: 100vh - 35px`
38,912,870
I am trying to pop up a tick (success) or cross (error) circular div on my pages as the result of a page post. I am close, but cannot quite get it centered. My HTML is added by JS upon page load, and shown for 1 second: ``` // Circle button alert popup function popupNotification(type) { if (type == 'success') { var popupButton = '<button type="button" id="popup-button" class="btn btn-success btn-circle btn-xl"><i class="glyphicon glyphicon-ok"></i></button>'; } else if (type == 'warning') { var popupButton = '<button type="button" id="popup-button" class="btn btn-warning btn-circle btn-xl"><i class="glyphicon glyphicon-warning-sign"></i></button>'; } else { var popupButton = '<button type="button" id="popup-button" class="btn btn-danger btn-circle btn-xl"><i class="glyphicon glyphicon-remove"></i></button>'; } $('body').append(popupButton); $('#popup-button').fadeIn('fast'); $("#popup-button").fadeTo(1000, 500).fadeOut(500, function(){ $("#popup-button").fadeOut(500); $("#popup-button").remove(); }); } ``` My CSS is: ``` #popup-button { position: fixed; z-index: 9999; top: 50%; left: 50%; opacity: 0.7; cursor: wait; } .btn-circle.btn-xl { width: 70px; height: 70px; padding: 10px 16px; font-size: 24px; line-height: 1.33; border-radius: 35px; } ``` This code centers the circular div with icon, but it is just off by half its width and half its height. I have tried the following without success: ``` #popup-button { position: fixed; z-index: 9999; top: 50% - 35px; left: 50% - 35px; opacity: 0.7; cursor: wait; } ``` Any ideas are highly appreciated!
2016/08/12
[ "https://Stackoverflow.com/questions/38912870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469528/" ]
I think it can be done without negative margins: ``` .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` Example: ```css .centered { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: red; width: 10px; height: 10px; } ``` ```html <div class="centered"> </div> ```
I agree with Adrian's answer. Using CSS3: ``` transform: translate(-50%, -50%); ``` Along with: ``` top: 50%; left: 50%; ``` Is a better solution as it's responsive, no matter the height or width of the parent you won't have to recalculate like some of the other solutions. Also don't forget to vendor prefix *transform* for various older versions of browsers, If you're using SASS I'd recommend this handy little [mixin](https://css-tricks.com/snippets/sass/mixin-prefix-properties/) by CSS Tricks.
166,329
My DM is usually very opposed to homebrew, and I can understand why, seeing as a lot of homebrews are ridiculous, but from a flavor and mechanics standpoint, this is exactly what I'm looking for. I've thought of combining classes for our game, but everything I've asked has either been ignored or shut down. I'm not trying to outshine other players or do everything, I just want to feel like Yojimbo. I am currently a kensei monk working towards battlemaster, but I won't be online until 9. The subclass in question is below (with most of the non-mechanical text abridged for brevity): --- > > Way of the Unmastered Monk > ========================== > > > Tread Down the Sword > -------------------- > > > Starting when you choose this this tradition at 3rd level, you gain proficiency with with two additional one-handed or versatile weapons of your choice, and can use these weapons as monk weapons with your Martial Arts class feature. In addition, when you successfully hit a creature with a monk weapon (but not an unarmed strike), you can spend 1 ki point to impose one of the following effects: > > > * It must succeed on a Strength saving throw or be disarmed > * It must succeed on a Constitution saving throw or receive disadvantage on ability checks and attack rolls for two rounds. > * It must succeed on a Charisma saving throw or be subject to the effects of *hunter's mark* spell for 5 rounds, on which you do not need to concentrate. > > > Waiting for the Initiative > -------------------------- > > > At 6th level, you seize the Initiative from the enemy on a failed strike. When an enemy's attack misses, you can spend 1 ki point as a reaction to make an attack with a monk weapon. If you took the Dodge action this turn, you may instead use your reaction to make an attack with a monk weapon under these circumstances at no cost. > > > No Master, No Name > ------------------ > > > Beginning at 11th level, you can't be unwillingly recognized unless a creature uses its action to inspect your appearance in detail. The creature must succeed on an Intelligence (Investigation) check against your ki save DC. You can spend a ki point to increase the difficulty of this check by 5 as a reaction to this check. > > > In addition, you can't be the subject of divination spells and can't be perceived by magical sensors unless the caster has a piece of your body or a highly personal possession, such as a piece of well-worn jewelry or a childhood treasure. These items no longer modify your saving throw against these effects, but are instead necessary to cast the spell at all. > > > One Strike, One Kill > -------------------- > > > Starting at 17th level, when you successfully hit with a monk weapon during an Attack action, you may spend 3 ki points to deal an additional 5d10 damage. If this damage reduces the target to 0 hit points, you may make an extra attack this turn as part of your Attack action. > > > --- [Source](https://homebrewery.naturalcrit.com/share/S1FK4pFX)
2020/03/13
[ "https://rpg.stackexchange.com/questions/166329", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/60461/" ]
This subclass is riddled with problems and is too strong ======================================================== This homebrew has a lot of problems that aren't really things you'd expect to see in an official class, and several of them are a lot stronger than what you could realistically expect to get. * Save vs. two rounds of disadvantage is really weird. These kinds of effects tend to be the next attack, or the next round, not two rounds, and especially not two rounds without getting a save to end it early. It mirrors the Poisoned condition to an extend, but weirder. * *Hunter's mark* for 5 rounds without concentration is a bad idea. Not only is it needlessly stepping on the Ranger class's turf, but it is another arbitrary number of rounds effect. * Waiting for the Initiative kind of steps on the Battle Master fighter's toes. This class essentially has the Riposte maneuver, and if you Dodge, it doesn't even cost you any ki. It's not as big a deal as the later features, but it's yet another "I do what you do, but better" feature in this class. In addition, the ki cost if you aren't dodging is a tad weird. For a bonus action and a ki point, you could be dodging and attack for free, so unless you really needed that bonus action, that's going to be the superior bang for your buck. * No Master, No Name is absurd. Assassin rogues can spend 7 days and a bunch of gold to create an elaborate cover at level 9, and can spend 3 hours at level 13 to convincingly copy somebody. This class just tosses that all out of the window and makes you permanently untrackable and unrecognizable unless people succeed in taking an action to even *try to recognize you* and only being able to do so by succeeding against a saving throw that you already wanted to maximize anyways. There is no reason why a level 11 Monk ability should invalidate entire classes and counter entire schools of magic so effectively. * One Strike, One Kill is another weird attempt to make the Assassin rogue feel worse about itself. Assassins, if they can successfully surprise somebody, can deal double damage if the target fails a con saving throw. This will add roughly 10d6 extra damage to their attack. This subclass, instead, gets to add 5d10 extra damage, without having to surprise, without allowing a saving throw, at the cost of 3 ki points. That's 5 times per short rest at level 17. At level 20, that becomes once per fight for free because of the level 20 feature giving you 4 Ki points. And it isn't even limited per round, you could hit twice in a round and deal an extra 10d10 damage. And then it also allows an extra weapon attack if you kill somebody, which will allow you to also use this feature again? That is absurd. I allow balanced homebrew at my table, and I would never even vaguely consider allowing this subclass. It's far too strong and does basically everything the Assassin does, but better. I also don't feel like having to track weird x rounds effects that aren't based on concentration.
In general, I find this subclass equal parts overpowered and poorly thought out. -------------------------------------------------------------------------------- ### Tread Down The Sword * The added proficiency is fine; eventually, you'll be using the monk damage die and weapon damage ceases to be relevant. * The disarm ability is fine. * The disadvantage ability is very strong when acquired, more than any other monk subtype gets this level, but becomes superfluous a few levels later. The fact that it lasts two rounds instead of just "until the end of the Monk's next turn" (as *Stunning Strike* does) is just odd. Once the character has *Stunning Strike*, this ability is overshadowed - why bother imposing disadvantage, when you can stop somebody cold. * The *hunter's mark* ability is overpowered by virtue of flexibility. Without concentration, it can be applied to any number of targets (subject to ki availability). The short duration also denies the secondary effect of making it easier to track somebody. ### Waiting for the Initiative I understand what the designer was going for here, but the wording is just clumsy. I even get the whole if-you-Dodged part, but it's almost never worth doing unless you're out of ki points or desperately afraid of being injured. You're far better off taking your two (three with Martial Arts or four with Flurry) attacks than just standing there *hoping* somebody misses you. Of course, Monks can *also* use *Patient Defense* to Dodge a bonus action, at the cost of a Ki point. The synergy there is entirely too strong. For a single ki point, you impose disadvantage on all incoming attacks *and* get the opportunity to swing back for free when somebody misses, all while making your two normal attacks. Then again, this could be another example of poor writing... If you look at exactly what was written, the monk must dodge *this turn*, not *this round*. If that's deliberate, it only works on opportunity attacks. Based on the [Iaido](https://en.wikipedia.org/wiki/Iaido) feel this ability seems to be going for, I suspect this is a rules-as-intended not matching rules-as-written. ### No Master, No Name This one is way out there. It is just flat out better than a disguise kit, because it always works without any advance preparation. It also blocks divination magic without any effort or cost. Compare this to other Monk abilities at the same level, most of which have a ki cost, an action cost, and generally only do one thing - this doesn't fit that pattern at all. ### One Strike, One Kill The effects of this ability do not even remotely match the name. There's no limit on the number of times it can be used in a round (therefore more-than-one-strike) and if the monk gets a kill, they get an extra swing (therefore more-than-one-kill becomes possible). On the positive side, it is at least ki driven.
66,349
I have to write my thesis in (German) law and we usually use a very nested headline system. I use `scrreprt` and have these levels: * (part) * chapter * section * subsection * subsubsection * paragraph * subparagraph But I need at least 3 more levels. They don't have to be in the ToC but it would be nice. I searched a lot and found a snippet that works but I can't reproduce it and create more levels. ``` % Fügt Gliederungsebene \subsubparagraph hinzu. \titleclass{\subsubparagraph}{straight}[\subparagraph] \makeatletter \newcounter{subsubsubsection}[subsubsection] \newcounter{subsubparagraph}[subparagraph] \newcommand*\l@subsubparagraph{\bprot@dottedtocline{6}{14em}{6em}} \makeatother ``` --- Somewhat related is my second question. Is there any way to rename some of the levels? It's always a little annoying trying to remember what comes after subsubsection etc. Maybe `\chapter`, `\section`, `\sub1section`, `\sub2section`, `\sub3section` or something else. Your help is greatly appreciated :)
2012/08/08
[ "https://tex.stackexchange.com/questions/66349", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/17269/" ]
Quoting the [manual](http://texdoc.org/pkg/titlesec) from the [`titlesec` package](http://ctan.org/pkg/titlesec): > > With the help of classes you may insert, say, a new subchapter level between chapter and section, or creating a scheme of your own. > > > (at subsection 3.9 in the `titlesec.pdf`). At appendix 9.2, it shows exactly how the already existing sections and the like are defined; don't copy the already existing parts to your file, but use them as inspiration for defining new ones (amount of indentation, style, etc). My advice is to look at all the appendices and subsection 3.9.
So thanks to everyone. I kind of fixed it: ``` \titleclass{\subAparagraph}{straight}[\subparagraph] \makeatletter \newcounter{subAparagraph}[subparagraph] \newcommand*\l@subAparagraph{\bprot@dottedtocline{6}{12em}{2.5em}} \makeatother \titleclass{\subBparagraph}{straight}[\subAparagraph] \makeatletter \newcounter{subBparagraph}[subAparagraph] \newcommand*\l@subBparagraph{\bprot@dottedtocline{7}{14em}{2.5em}} \makeatother \titleclass{\subCparagraph}{straight}[\subBparagraph] \makeatletter \newcounter{subCparagraph}[subBparagraph] \newcommand*\l@subCparagraph{\bprot@dottedtocline{8}{16em}{2.5em}} \makeatother ``` I use alnumsec to make the Symbols: ``` \usepackage{alnumsec} \alnumsectionlevels{0}{chapter,section,subsection,subsubsection,paragraph,subparagraph,subAparagraph,subBparagraph,subCparagraph} \otherseparators{4} \surroundarabic[(][)]{}{.} \surroundgreek[][)]{}{.} \alnumsecstyle{LRaldagbr} ``` And formating: ``` \titlespacing{\subAparagraph}{0em}{0em}{0em} \titlespacing{\subBparagraph}{0em}{0em}{0em} \titlespacing{\subCparagraph}{0em}{0em}{0em} \titleformat{\subAparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubAparagraph\quad}{0pt}{} \titleformat{\subBparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubBparagraph\quad}{0pt}{} \titleformat{\subCparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubCparagraph\quad}{0pt}{} ``` --- I also noticed (after writing one paper with near identical settings and not noticing this) that the counter was not resetting if the exact previous level was not called. ![Reset Counter](https://i.stack.imgur.com/cR4Mv.png) I fixed this with adding every "higher" level to reset (`\usepackage{remreset}`) ``` \makeatletter \@addtoreset{subCparagraph}{part} \@addtoreset{subCparagraph}{chapter} \@addtoreset{subCparagraph}{section} \@addtoreset{subCparagraph}{subsection} \@addtoreset{subCparagraph}{subsubsection} \@addtoreset{subCparagraph}{paragraph} \@addtoreset{subCparagraph}{subparagraph} \@addtoreset{subCparagraph}{subAparagraph} \makeatother ``` (This also affects the default levels like section) This is kind of a bulky macro since you have to add something similar (only add the higher levels) for every level and I guess I will remove it so that I can see where I made an enumeration error :)
66,349
I have to write my thesis in (German) law and we usually use a very nested headline system. I use `scrreprt` and have these levels: * (part) * chapter * section * subsection * subsubsection * paragraph * subparagraph But I need at least 3 more levels. They don't have to be in the ToC but it would be nice. I searched a lot and found a snippet that works but I can't reproduce it and create more levels. ``` % Fügt Gliederungsebene \subsubparagraph hinzu. \titleclass{\subsubparagraph}{straight}[\subparagraph] \makeatletter \newcounter{subsubsubsection}[subsubsection] \newcounter{subsubparagraph}[subparagraph] \newcommand*\l@subsubparagraph{\bprot@dottedtocline{6}{14em}{6em}} \makeatother ``` --- Somewhat related is my second question. Is there any way to rename some of the levels? It's always a little annoying trying to remember what comes after subsubsection etc. Maybe `\chapter`, `\section`, `\sub1section`, `\sub2section`, `\sub3section` or something else. Your help is greatly appreciated :)
2012/08/08
[ "https://tex.stackexchange.com/questions/66349", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/17269/" ]
Quoting the [manual](http://texdoc.org/pkg/titlesec) from the [`titlesec` package](http://ctan.org/pkg/titlesec): > > With the help of classes you may insert, say, a new subchapter level between chapter and section, or creating a scheme of your own. > > > (at subsection 3.9 in the `titlesec.pdf`). At appendix 9.2, it shows exactly how the already existing sections and the like are defined; don't copy the already existing parts to your file, but use them as inspiration for defining new ones (amount of indentation, style, etc). My advice is to look at all the appendices and subsection 3.9.
Since the question is about a KOMA-class, we can use KOMA features to define new levels of structuring commands. [![niclasKomaExtraLevel](https://i.stack.imgur.com/Ytut2.png)](https://i.stack.imgur.com/Ytut2.png) ``` \documentclass{scrartcl} \makeatletter \DeclareSectionCommand[% tocindent=9.0em,% ]{subparagraph} \DeclareSectionCommand[% style=section,% level=6,% indent=2.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=10.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Aparagraph} \DeclareSectionCommand[% style=section,% level=7,% indent=3.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=11.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Bparagraph} \DeclareSectionCommand[% style=section,% level=8,% indent=4.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=12.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Cparagraph} \makeatother \setcounter{tocdepth}{7} \begin{document} \tableofcontents \section{Wombat} \subsection{Capybara} \subsubsection{Mara} \paragraph{Zebra} \subparagraph{Elephant} \Aparagraph{Giraffe} \Bparagraph{Quail} \Cparagraph{Duck} \end{document} ``` Of course you don't really need `\makeatletter` and `\makeitother` if you don't use low level commands. I used them, because i copied the bits straight from the class file.
66,349
I have to write my thesis in (German) law and we usually use a very nested headline system. I use `scrreprt` and have these levels: * (part) * chapter * section * subsection * subsubsection * paragraph * subparagraph But I need at least 3 more levels. They don't have to be in the ToC but it would be nice. I searched a lot and found a snippet that works but I can't reproduce it and create more levels. ``` % Fügt Gliederungsebene \subsubparagraph hinzu. \titleclass{\subsubparagraph}{straight}[\subparagraph] \makeatletter \newcounter{subsubsubsection}[subsubsection] \newcounter{subsubparagraph}[subparagraph] \newcommand*\l@subsubparagraph{\bprot@dottedtocline{6}{14em}{6em}} \makeatother ``` --- Somewhat related is my second question. Is there any way to rename some of the levels? It's always a little annoying trying to remember what comes after subsubsection etc. Maybe `\chapter`, `\section`, `\sub1section`, `\sub2section`, `\sub3section` or something else. Your help is greatly appreciated :)
2012/08/08
[ "https://tex.stackexchange.com/questions/66349", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/17269/" ]
Since the question is about a KOMA-class, we can use KOMA features to define new levels of structuring commands. [![niclasKomaExtraLevel](https://i.stack.imgur.com/Ytut2.png)](https://i.stack.imgur.com/Ytut2.png) ``` \documentclass{scrartcl} \makeatletter \DeclareSectionCommand[% tocindent=9.0em,% ]{subparagraph} \DeclareSectionCommand[% style=section,% level=6,% indent=2.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=10.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Aparagraph} \DeclareSectionCommand[% style=section,% level=7,% indent=3.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=11.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Bparagraph} \DeclareSectionCommand[% style=section,% level=8,% indent=4.0\scr@parindent,% beforeskip=3.25ex \@plus1ex \@minus.2ex,% afterskip=-1em,% tocstyle=subsection,% tocindent=12.0em,% tocnumwidth=4.1em% ,font=\normalcolor\normalsize\bfseries\sffamily,% ]{Cparagraph} \makeatother \setcounter{tocdepth}{7} \begin{document} \tableofcontents \section{Wombat} \subsection{Capybara} \subsubsection{Mara} \paragraph{Zebra} \subparagraph{Elephant} \Aparagraph{Giraffe} \Bparagraph{Quail} \Cparagraph{Duck} \end{document} ``` Of course you don't really need `\makeatletter` and `\makeitother` if you don't use low level commands. I used them, because i copied the bits straight from the class file.
So thanks to everyone. I kind of fixed it: ``` \titleclass{\subAparagraph}{straight}[\subparagraph] \makeatletter \newcounter{subAparagraph}[subparagraph] \newcommand*\l@subAparagraph{\bprot@dottedtocline{6}{12em}{2.5em}} \makeatother \titleclass{\subBparagraph}{straight}[\subAparagraph] \makeatletter \newcounter{subBparagraph}[subAparagraph] \newcommand*\l@subBparagraph{\bprot@dottedtocline{7}{14em}{2.5em}} \makeatother \titleclass{\subCparagraph}{straight}[\subBparagraph] \makeatletter \newcounter{subCparagraph}[subBparagraph] \newcommand*\l@subCparagraph{\bprot@dottedtocline{8}{16em}{2.5em}} \makeatother ``` I use alnumsec to make the Symbols: ``` \usepackage{alnumsec} \alnumsectionlevels{0}{chapter,section,subsection,subsubsection,paragraph,subparagraph,subAparagraph,subBparagraph,subCparagraph} \otherseparators{4} \surroundarabic[(][)]{}{.} \surroundgreek[][)]{}{.} \alnumsecstyle{LRaldagbr} ``` And formating: ``` \titlespacing{\subAparagraph}{0em}{0em}{0em} \titlespacing{\subBparagraph}{0em}{0em}{0em} \titlespacing{\subCparagraph}{0em}{0em}{0em} \titleformat{\subAparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubAparagraph\quad}{0pt}{} \titleformat{\subBparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubBparagraph\quad}{0pt}{} \titleformat{\subCparagraph}[hang]{\normalfont\normalsize\bfseries}{\thesubCparagraph\quad}{0pt}{} ``` --- I also noticed (after writing one paper with near identical settings and not noticing this) that the counter was not resetting if the exact previous level was not called. ![Reset Counter](https://i.stack.imgur.com/cR4Mv.png) I fixed this with adding every "higher" level to reset (`\usepackage{remreset}`) ``` \makeatletter \@addtoreset{subCparagraph}{part} \@addtoreset{subCparagraph}{chapter} \@addtoreset{subCparagraph}{section} \@addtoreset{subCparagraph}{subsection} \@addtoreset{subCparagraph}{subsubsection} \@addtoreset{subCparagraph}{paragraph} \@addtoreset{subCparagraph}{subparagraph} \@addtoreset{subCparagraph}{subAparagraph} \makeatother ``` (This also affects the default levels like section) This is kind of a bulky macro since you have to add something similar (only add the higher levels) for every level and I guess I will remove it so that I can see where I made an enumeration error :)
30,369,903
A JavaScript function is returning a div in double quote. like - ``` function Callback() { return "<div> <a href='javascript:void(0); > ENGLISH </a> </div>"; } ``` I want to check if document.getElementById('language').value == ENGLISH then apply color to ENGLISH word. So how to match JavaScript variable with concatenate. Thanks In Advance.
2015/05/21
[ "https://Stackoverflow.com/questions/30369903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2094586/" ]
Try this: ``` <div id='testElem'><a href='javascript:void(0)'>ENGLISH</a></div> <script> function Callback() { return "<div id='testElem'><a href='javascript:void(0)'>ENGLISH</a></div>"; } function check() { if(document.getElementById('language').value == "ENGLISH") { console.log(document.getElementById("testElem").childNodes[0].style.color = 'red'); } } check(); </script> ```
Not sure if this is what you want : ``` <div id="language" value="ENGLISH"> </div> var cookieValue = document.getElementById("language").getAttribute('value'); if(cookieValue == "ENGLISH"){ document.getElementById("language").style.color = "green"; } ```
30,369,903
A JavaScript function is returning a div in double quote. like - ``` function Callback() { return "<div> <a href='javascript:void(0); > ENGLISH </a> </div>"; } ``` I want to check if document.getElementById('language').value == ENGLISH then apply color to ENGLISH word. So how to match JavaScript variable with concatenate. Thanks In Advance.
2015/05/21
[ "https://Stackoverflow.com/questions/30369903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2094586/" ]
``` function Callback() { return "<div id='language'><a href='javascript:void(0);'> ENGLISH </a></div>"; } var jslanguage=document.getElementById("language").textContent; jslanguage=jslanguage.trim() ;// will get the text ENGLISH. if(jslanguage== "ENGLISH"){ document.getElementById("language").style.color = "green"; } ```
Not sure if this is what you want : ``` <div id="language" value="ENGLISH"> </div> var cookieValue = document.getElementById("language").getAttribute('value'); if(cookieValue == "ENGLISH"){ document.getElementById("language").style.color = "green"; } ```
30,369,903
A JavaScript function is returning a div in double quote. like - ``` function Callback() { return "<div> <a href='javascript:void(0); > ENGLISH </a> </div>"; } ``` I want to check if document.getElementById('language').value == ENGLISH then apply color to ENGLISH word. So how to match JavaScript variable with concatenate. Thanks In Advance.
2015/05/21
[ "https://Stackoverflow.com/questions/30369903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2094586/" ]
Try this: ``` <div id='testElem'><a href='javascript:void(0)'>ENGLISH</a></div> <script> function Callback() { return "<div id='testElem'><a href='javascript:void(0)'>ENGLISH</a></div>"; } function check() { if(document.getElementById('language').value == "ENGLISH") { console.log(document.getElementById("testElem").childNodes[0].style.color = 'red'); } } check(); </script> ```
``` function Callback() { return "<div id='language'><a href='javascript:void(0);'> ENGLISH </a></div>"; } var jslanguage=document.getElementById("language").textContent; jslanguage=jslanguage.trim() ;// will get the text ENGLISH. if(jslanguage== "ENGLISH"){ document.getElementById("language").style.color = "green"; } ```
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
I was looking for simple solution to remove views from viewpager (no fragments) dynamically. So, if you have some info, that your pages belongs to, you can set it to View as tag. Just like that (adapter code): ``` @Override public Object instantiateItem(ViewGroup collection, int position) { ImageView iv = new ImageView(mContext); MediaMessage msg = mMessages.get(position); ... iv.setTag(media); return iv; } @Override public int getItemPosition (Object object) { View o = (View) object; int index = mMessages.indexOf(o.getTag()); if (index == -1) return POSITION_NONE; else return index; } ``` You just need remove your info from mMessages, and then call `notifyDataSetChanged()` for your adapter. Bad news there is no animation in this case.
I've created a [custom PagerAdapters library](https://github.com/takaaki7/ArrayPagerAdapter) to change items in PagerAdapters dynamically. You can change items dynamically like following by using this library. ``` @Override protected void onCreate(Bundle savedInstanceState) { /** ... **/ adapter = new MyStatePagerAdapter(getSupportFragmentManager() , new String[]{"1", "2", "3"}); ((ViewPager)findViewById(R.id.view_pager)).setAdapter(adapter); adapter.add("4"); adapter.remove(0); } class MyPagerAdapter extends ArrayViewPagerAdapter<String> { public MyPagerAdapter(String[] data) { super(data); } @Override public View getView(LayoutInflater inflater, ViewGroup container, String item, int position) { View v = inflater.inflate(R.layout.item_page, container, false); ((TextView) v.findViewById(R.id.item_txt)).setText(item); return v; } } ``` Thils library also support pages created by Fragments.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
I was looking for simple solution to remove views from viewpager (no fragments) dynamically. So, if you have some info, that your pages belongs to, you can set it to View as tag. Just like that (adapter code): ``` @Override public Object instantiateItem(ViewGroup collection, int position) { ImageView iv = new ImageView(mContext); MediaMessage msg = mMessages.get(position); ... iv.setTag(media); return iv; } @Override public int getItemPosition (Object object) { View o = (View) object; int index = mMessages.indexOf(o.getTag()); if (index == -1) return POSITION_NONE; else return index; } ``` You just need remove your info from mMessages, and then call `notifyDataSetChanged()` for your adapter. Bad news there is no animation in this case.
I find a good solution for this issue, this solution can make it work and no need to recreate Fragments. My key point is: 1. **setup ViewPager every time you delete or add Tab(Fragment).** 2. **Override the getItemId method, return a specific id rather than position.** Source Code ``` package com.zq.testviewpager; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.ArrayList; import java.util.Arrays; /** * Created by z8888q@gmail.com on 2017/5/31. * Implement dynamic delete or add tab(TAB_C in this test code). */ public class MainActivity extends AppCompatActivity { private static final int TAB_A = 1001; private static final int TAB_B = 1002; private static final int TAB_C = 1003; private static final int TAB_D = 1004; private static final int TAB_E = 1005; private Tab[] tabsArray = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_C, "C"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs = new ArrayList<>(Arrays.asList(tabsArray)); private Tab[] tabsArray2 = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs2 = new ArrayList<>(Arrays.asList(tabsArray2)); /** * The {@link android.support.v4.view.PagerAdapter} that will provide * fragments for each of the sections. We use a * {@link FragmentPagerAdapter} derivative, which will keep every * loaded fragment in memory. If this becomes too memory intensive, it * may be best to switch to a * {@link android.support.v4.app.FragmentStatePagerAdapter}. */ private SectionsPagerAdapter mSectionsPagerAdapter; /** * The {@link ViewPager} that will host the section contents. */ private ViewPager mViewPager; private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; }else if (id == R.id.action_delete) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs.get(currentItemPosition); if(currentTab.id == TAB_C){ currentTab = mTabs.get(currentItemPosition == 0 ? currentItemPosition +1 : currentItemPosition - 1); } mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs2, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs2.indexOf(currentTab), false); return true; }else if (id == R.id.action_add) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs2.get(currentItemPosition); mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs.indexOf(currentTab), false); return true; }else return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; public PlaceholderFragment() { } /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("TestViewPager", "onCreate"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public void onDestroy() { super.onDestroy(); Log.e("TestViewPager", "onDestroy"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); TextView textView = (TextView) rootView.findViewById(R.id.section_label); textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); return rootView; } } /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ public class SectionsPagerAdapter extends FragmentPagerAdapter { ArrayList<Tab> tabs; public SectionsPagerAdapter(ArrayList<Tab> tabs, FragmentManager fm) { super(fm); this.tabs = tabs; } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). return PlaceholderFragment.newInstance(tabs.get(position).id); } @Override public int getCount() { return tabs.size(); } @Override public long getItemId(int position) { return tabs.get(position).id; } @Override public CharSequence getPageTitle(int position) { return tabs.get(position).title; } } private static class Tab { String title; public int id; Tab(int id, String title){ this.id = id; this.title = title; } @Override public boolean equals(Object obj) { if(obj instanceof Tab){ return ((Tab)obj).id == id; }else{ return false; } } } } ``` Code is at my [Github Gist](https://gist.github.com/z8888q/056ff15d7bfa5fff57985bf4f08e907b).
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
After figuring out which ViewPager methods are called by ViewPager and which are for other purposes, I came up with a solution. I present it here since I see a lot of people have struggled with this and I didn't see any other relevant answers. First, here's my adapter; hopefully comments within the code are sufficient: ``` public class MainPagerAdapter extends PagerAdapter { // This holds all the currently displayable views, in order from left to right. private ArrayList<View> views = new ArrayList<View>(); //----------------------------------------------------------------------------- // Used by ViewPager. "Object" represents the page; tell the ViewPager where the // page should be displayed, from left-to-right. If the page no longer exists, // return POSITION_NONE. @Override public int getItemPosition (Object object) { int index = views.indexOf (object); if (index == -1) return POSITION_NONE; else return index; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager needs a page to display; it is our job // to add the page to the container, which is normally the ViewPager itself. Since // all our pages are persistent, we simply retrieve it from our "views" ArrayList. @Override public Object instantiateItem (ViewGroup container, int position) { View v = views.get (position); container.addView (v); return v; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager no longer needs a page to display; it // is our job to remove the page from the container, which is normally the // ViewPager itself. Since all our pages are persistent, we do nothing to the // contents of our "views" ArrayList. @Override public void destroyItem (ViewGroup container, int position, Object object) { container.removeView (views.get (position)); } //----------------------------------------------------------------------------- // Used by ViewPager; can be used by app as well. // Returns the total number of pages that the ViewPage can display. This must // never be 0. @Override public int getCount () { return views.size(); } //----------------------------------------------------------------------------- // Used by ViewPager. @Override public boolean isViewFromObject (View view, Object object) { return view == object; } //----------------------------------------------------------------------------- // Add "view" to right end of "views". // Returns the position of the new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v) { return addView (v, views.size()); } //----------------------------------------------------------------------------- // Add "view" at "position" to "views". // Returns position of new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v, int position) { views.add (position, v); return position; } //----------------------------------------------------------------------------- // Removes "view" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, View v) { return removeView (pager, views.indexOf (v)); } //----------------------------------------------------------------------------- // Removes the "view" at "position" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, int position) { // ViewPager doesn't have a delete method; the closest is to set the adapter // again. When doing so, it deletes all its views. Then we can delete the view // from from the adapter and finally set the adapter to the pager again. Note // that we set the adapter to null before removing the view from "views" - that's // because while ViewPager deletes all its views, it will call destroyItem which // will in turn cause a null pointer ref. pager.setAdapter (null); views.remove (position); pager.setAdapter (this); return position; } //----------------------------------------------------------------------------- // Returns the "view" at "position". // The app should call this to retrieve a view; not used by ViewPager. public View getView (int position) { return views.get (position); } // Other relevant methods: // finishUpdate - called by the ViewPager - we don't care about what pages the // pager is displaying so we don't use this method. } ``` And here's some snips of code showing how to use the adapter. ``` class MainActivity extends Activity { private ViewPager pager = null; private MainPagerAdapter pagerAdapter = null; //----------------------------------------------------------------------------- @Override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView (R.layout.main_activity); ... do other initialization, such as create an ActionBar ... pagerAdapter = new MainPagerAdapter(); pager = (ViewPager) findViewById (R.id.view_pager); pager.setAdapter (pagerAdapter); // Create an initial view to display; must be a subclass of FrameLayout. LayoutInflater inflater = context.getLayoutInflater(); FrameLayout v0 = (FrameLayout) inflater.inflate (R.layout.one_of_my_page_layouts, null); pagerAdapter.addView (v0, 0); pagerAdapter.notifyDataSetChanged(); } //----------------------------------------------------------------------------- // Here's what the app should do to add a view to the ViewPager. public void addView (View newPage) { int pageIndex = pagerAdapter.addView (newPage); // You might want to make "newPage" the currently displayed page: pager.setCurrentItem (pageIndex, true); } //----------------------------------------------------------------------------- // Here's what the app should do to remove a view from the ViewPager. public void removeView (View defunctPage) { int pageIndex = pagerAdapter.removeView (pager, defunctPage); // You might want to choose what page to display, if the current page was "defunctPage". if (pageIndex == pagerAdapter.getCount()) pageIndex--; pager.setCurrentItem (pageIndex); } //----------------------------------------------------------------------------- // Here's what the app should do to get the currently displayed page. public View getCurrentPage () { return pagerAdapter.getView (pager.getCurrentItem()); } //----------------------------------------------------------------------------- // Here's what the app should do to set the currently displayed page. "pageToShow" must // currently be in the adapter, or this will crash. public void setCurrentPage (View pageToShow) { pager.setCurrentItem (pagerAdapter.getItemPosition (pageToShow), true); } } ``` Finally, you can use the following for your `activity_main.xml` layout: ``` <?xml version="1.0" encoding="utf-8"?> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> ```
I've created a [custom PagerAdapters library](https://github.com/takaaki7/ArrayPagerAdapter) to change items in PagerAdapters dynamically. You can change items dynamically like following by using this library. ``` @Override protected void onCreate(Bundle savedInstanceState) { /** ... **/ adapter = new MyStatePagerAdapter(getSupportFragmentManager() , new String[]{"1", "2", "3"}); ((ViewPager)findViewById(R.id.view_pager)).setAdapter(adapter); adapter.add("4"); adapter.remove(0); } class MyPagerAdapter extends ArrayViewPagerAdapter<String> { public MyPagerAdapter(String[] data) { super(data); } @Override public View getView(LayoutInflater inflater, ViewGroup container, String item, int position) { View v = inflater.inflate(R.layout.item_page, container, false); ((TextView) v.findViewById(R.id.item_txt)).setText(item); return v; } } ``` Thils library also support pages created by Fragments.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
After figuring out which ViewPager methods are called by ViewPager and which are for other purposes, I came up with a solution. I present it here since I see a lot of people have struggled with this and I didn't see any other relevant answers. First, here's my adapter; hopefully comments within the code are sufficient: ``` public class MainPagerAdapter extends PagerAdapter { // This holds all the currently displayable views, in order from left to right. private ArrayList<View> views = new ArrayList<View>(); //----------------------------------------------------------------------------- // Used by ViewPager. "Object" represents the page; tell the ViewPager where the // page should be displayed, from left-to-right. If the page no longer exists, // return POSITION_NONE. @Override public int getItemPosition (Object object) { int index = views.indexOf (object); if (index == -1) return POSITION_NONE; else return index; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager needs a page to display; it is our job // to add the page to the container, which is normally the ViewPager itself. Since // all our pages are persistent, we simply retrieve it from our "views" ArrayList. @Override public Object instantiateItem (ViewGroup container, int position) { View v = views.get (position); container.addView (v); return v; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager no longer needs a page to display; it // is our job to remove the page from the container, which is normally the // ViewPager itself. Since all our pages are persistent, we do nothing to the // contents of our "views" ArrayList. @Override public void destroyItem (ViewGroup container, int position, Object object) { container.removeView (views.get (position)); } //----------------------------------------------------------------------------- // Used by ViewPager; can be used by app as well. // Returns the total number of pages that the ViewPage can display. This must // never be 0. @Override public int getCount () { return views.size(); } //----------------------------------------------------------------------------- // Used by ViewPager. @Override public boolean isViewFromObject (View view, Object object) { return view == object; } //----------------------------------------------------------------------------- // Add "view" to right end of "views". // Returns the position of the new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v) { return addView (v, views.size()); } //----------------------------------------------------------------------------- // Add "view" at "position" to "views". // Returns position of new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v, int position) { views.add (position, v); return position; } //----------------------------------------------------------------------------- // Removes "view" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, View v) { return removeView (pager, views.indexOf (v)); } //----------------------------------------------------------------------------- // Removes the "view" at "position" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, int position) { // ViewPager doesn't have a delete method; the closest is to set the adapter // again. When doing so, it deletes all its views. Then we can delete the view // from from the adapter and finally set the adapter to the pager again. Note // that we set the adapter to null before removing the view from "views" - that's // because while ViewPager deletes all its views, it will call destroyItem which // will in turn cause a null pointer ref. pager.setAdapter (null); views.remove (position); pager.setAdapter (this); return position; } //----------------------------------------------------------------------------- // Returns the "view" at "position". // The app should call this to retrieve a view; not used by ViewPager. public View getView (int position) { return views.get (position); } // Other relevant methods: // finishUpdate - called by the ViewPager - we don't care about what pages the // pager is displaying so we don't use this method. } ``` And here's some snips of code showing how to use the adapter. ``` class MainActivity extends Activity { private ViewPager pager = null; private MainPagerAdapter pagerAdapter = null; //----------------------------------------------------------------------------- @Override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView (R.layout.main_activity); ... do other initialization, such as create an ActionBar ... pagerAdapter = new MainPagerAdapter(); pager = (ViewPager) findViewById (R.id.view_pager); pager.setAdapter (pagerAdapter); // Create an initial view to display; must be a subclass of FrameLayout. LayoutInflater inflater = context.getLayoutInflater(); FrameLayout v0 = (FrameLayout) inflater.inflate (R.layout.one_of_my_page_layouts, null); pagerAdapter.addView (v0, 0); pagerAdapter.notifyDataSetChanged(); } //----------------------------------------------------------------------------- // Here's what the app should do to add a view to the ViewPager. public void addView (View newPage) { int pageIndex = pagerAdapter.addView (newPage); // You might want to make "newPage" the currently displayed page: pager.setCurrentItem (pageIndex, true); } //----------------------------------------------------------------------------- // Here's what the app should do to remove a view from the ViewPager. public void removeView (View defunctPage) { int pageIndex = pagerAdapter.removeView (pager, defunctPage); // You might want to choose what page to display, if the current page was "defunctPage". if (pageIndex == pagerAdapter.getCount()) pageIndex--; pager.setCurrentItem (pageIndex); } //----------------------------------------------------------------------------- // Here's what the app should do to get the currently displayed page. public View getCurrentPage () { return pagerAdapter.getView (pager.getCurrentItem()); } //----------------------------------------------------------------------------- // Here's what the app should do to set the currently displayed page. "pageToShow" must // currently be in the adapter, or this will crash. public void setCurrentPage (View pageToShow) { pager.setCurrentItem (pagerAdapter.getItemPosition (pageToShow), true); } } ``` Finally, you can use the following for your `activity_main.xml` layout: ``` <?xml version="1.0" encoding="utf-8"?> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> ```
To remove you can use this directly: ``` getSupportFragmentManager().beginTransaction().remove(fragment). commitAllowingStateLoss(); ``` `fragment` is the fragment you want to remove.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
I did a similar program. hope this would help you.In its first activity four grid data can be selected. On the next activity, there is a view pager which contains two mandatory pages.And 4 more pages will be there, which will be visible corresponding to the grid data selected. Following is the mainactivty MainActivity ``` package com.example.jeffy.viewpagerapp; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.os.Bundle; import android.os.Parcel; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.view.Menu; import android.view.MenuItem; import android.widget.AdapterView; import android.widget.Button; import android.widget.GridView; import java.lang.reflect.Array; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { SharedPreferences pref; SharedPreferences.Editor editor; GridView gridView; Button button; private static final String DATABASE_NAME = "dbForTest.db"; private static final int DATABASE_VERSION = 1; private static final String TABLE_NAME = "diary"; private static final String TITLE = "id"; private static final String BODY = "content"; DBHelper dbHelper = new DBHelper(this); ArrayList<String> frags = new ArrayList<String>(); ArrayList<FragmentArray> fragmentArray = new ArrayList<FragmentArray>(); String[] selectedData; Boolean port1=false,port2=false,port3=false,port4=false; int Iport1=1,Iport2=1,Iport3=1,Iport4=1,location; // This Data show in grid ( Used by adapter ) CustomGridAdapter customGridAdapter = new CustomGridAdapter(MainActivity.this,GRID_DATA); static final String[ ] GRID_DATA = new String[] { "1" , "2", "3" , "4" }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); frags.add("TabFragment3"); frags.add("TabFragment4"); frags.add("TabFragment5"); frags.add("TabFragment6"); dbHelper = new DBHelper(this); dbHelper.insertContact(1,0); dbHelper.insertContact(2,0); dbHelper.insertContact(3,0); dbHelper.insertContact(4,0); final Bundle selected = new Bundle(); button = (Button) findViewById(R.id.button); pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE); editor = pref.edit(); gridView = (GridView) findViewById(R.id.gridView1); gridView.setAdapter(customGridAdapter); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //view.findViewById(R.id.grid_item_image).setVisibility(View.VISIBLE); location = position + 1; if (position == 0) { Iport1++; Iport1 = Iport1 % 2; if (Iport1 % 2 == 1) { //dbHelper.updateContact(1,1); view.findViewById(R.id.grid_item_image).setVisibility(View.VISIBLE); dbHelper.updateContact(1,1); } else { //dbHelper.updateContact(1,0); view.findViewById(R.id.grid_item_image).setVisibility(View.INVISIBLE); dbHelper.updateContact(1, 0); } } if (position == 1) { Iport2++; Iport1 = Iport1 % 2; if (Iport2 % 2 == 1) { //dbHelper.updateContact(2,1); view.findViewById(R.id.grid_item_image).setVisibility(View.VISIBLE); dbHelper.updateContact(2, 1); } else { //dbHelper.updateContact(2,0); view.findViewById(R.id.grid_item_image).setVisibility(View.INVISIBLE); dbHelper.updateContact(2,0); } } if (position == 2) { Iport3++; Iport3 = Iport3 % 2; if (Iport3 % 2 == 1) { //dbHelper.updateContact(3,1); view.findViewById(R.id.grid_item_image).setVisibility(View.VISIBLE); dbHelper.updateContact(3, 1); } else { //dbHelper.updateContact(3,0); view.findViewById(R.id.grid_item_image).setVisibility(View.INVISIBLE); dbHelper.updateContact(3, 0); } } if (position == 3) { Iport4++; Iport4 = Iport4 % 2; if (Iport4 % 2 == 1) { //dbHelper.updateContact(4,1); view.findViewById(R.id.grid_item_image).setVisibility(View.VISIBLE); dbHelper.updateContact(4, 1); } else { //dbHelper.updateContact(4,0); view.findViewById(R.id.grid_item_image).setVisibility(View.INVISIBLE); dbHelper.updateContact(4,0); } } } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editor.putInt("port1", Iport1); editor.putInt("port2", Iport2); editor.putInt("port3", Iport3); editor.putInt("port4", Iport4); Intent i = new Intent(MainActivity.this,Main2Activity.class); if(Iport1==1) i.putExtra("3","TabFragment3"); else i.putExtra("3", ""); if(Iport2==1) i.putExtra("4","TabFragment4"); else i.putExtra("4",""); if(Iport3==1) i.putExtra("5", "TabFragment5"); else i.putExtra("5",""); if(Iport4==1) i.putExtra("6", "TabFragment6"); else i.putExtra("6",""); dbHelper.updateContact(0, Iport1); dbHelper.updateContact(1, Iport2); dbHelper.updateContact(2, Iport3); dbHelper.updateContact(3, Iport4); startActivity(i); } }); } } ``` Here TabFragment1,TabFragment2 etc are fragment to be displayed on the viewpager.And I am not showing the layouts since they are out of scope of this project. MainActivity will intent to Main2Activity Main2Activity ``` package com.example.jeffy.viewpagerapp; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.support.v4.widget.NestedScrollView; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.FrameLayout; import java.util.ArrayList; public class Main2Activity extends AppCompatActivity { private ViewPager pager = null; private PagerAdapter pagerAdapter = null; DBHelper dbHelper; Cursor rs; int port1,port2,port3,port4; //----------------------------------------------------------------------------- @Override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Toolbar toolbar = (Toolbar) findViewById(R.id.MyToolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapse_toolbar); NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.nested); scrollView.setFillViewport (true); ArrayList<String > selectedPort = new ArrayList<String>(); Intent intent = getIntent(); String Tab3 = intent.getStringExtra("3"); String Tab4 = intent.getStringExtra("4"); String Tab5 = intent.getStringExtra("5"); String Tab6 = intent.getStringExtra("6"); TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); tabLayout.addTab(tabLayout.newTab().setText("View")); tabLayout.addTab(tabLayout.newTab().setText("All")); selectedPort.add("TabFragment1"); selectedPort.add("TabFragment2"); if(Tab3!=null && !TextUtils.isEmpty(Tab3)) selectedPort.add(Tab3); if(Tab4!=null && !TextUtils.isEmpty(Tab4)) selectedPort.add(Tab4); if(Tab5!=null && !TextUtils.isEmpty(Tab5)) selectedPort.add(Tab5); if(Tab6!=null && !TextUtils.isEmpty(Tab6)) selectedPort.add(Tab6); dbHelper = new DBHelper(this); // rs=dbHelper.getData(1); // port1 = rs.getInt(rs.getColumnIndex("id")); // // rs=dbHelper.getData(2); // port2 = rs.getInt(rs.getColumnIndex("id")); // // rs=dbHelper.getData(3); // port3 = rs.getInt(rs.getColumnIndex("id")); // // rs=dbHelper.getData(4); // port4 = rs.getInt(rs.getColumnIndex("id")); Log.i(">>>>>>>>>>>>>>", "port 1" + port1 + "port 2" + port2 + "port 3" + port3 + "port 4" + port4); if(Tab3!=null && !TextUtils.isEmpty(Tab3)) tabLayout.addTab(tabLayout.newTab().setText("Tab 0")); if(Tab3!=null && !TextUtils.isEmpty(Tab4)) tabLayout.addTab(tabLayout.newTab().setText("Tab 1")); if(Tab3!=null && !TextUtils.isEmpty(Tab5)) tabLayout.addTab(tabLayout.newTab().setText("Tab 2")); if(Tab3!=null && !TextUtils.isEmpty(Tab6)) tabLayout.addTab(tabLayout.newTab().setText("Tab 3")); tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); final ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); final PagerAdapter adapter = new PagerAdapter (getSupportFragmentManager(), tabLayout.getTabCount(), selectedPort); viewPager.setAdapter(adapter); viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); // setContentView(R.layout.activity_main2); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); // tabLayout.addTab(tabLayout.newTab().setText("View")); // tabLayout.addTab(tabLayout.newTab().setText("All")); // tabLayout.addTab(tabLayout.newTab().setText("Tab 0")); // tabLayout.addTab(tabLayout.newTab().setText("Tab 1")); // tabLayout.addTab(tabLayout.newTab().setText("Tab 2")); // tabLayout.addTab(tabLayout.newTab().setText("Tab 3")); // tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); } } ``` ViewPagerAdapter Viewpageradapter.class ``` package com.example.jeffy.viewpagerapp; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List; /** * Created by Jeffy on 25-01-2016. */ public class PagerAdapter extends FragmentStatePagerAdapter { int mNumOfTabs; List<String> values; public PagerAdapter(FragmentManager fm, int NumOfTabs, List<String> Port) { super(fm); this.mNumOfTabs = NumOfTabs; this.values= Port; } @Override public Fragment getItem(int position) { String fragmentName = values.get(position); Class<?> clazz = null; Object fragment = null; try { clazz = Class.forName("com.example.jeffy.viewpagerapp."+fragmentName); } catch (ClassNotFoundException e) { e.printStackTrace(); } try { fragment = clazz.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return (Fragment) fragment; } @Override public int getCount() { return values.size(); } } ``` Layout for main2activity acticity\_main2.xml ``` <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.design.widget.AppBarLayout android:id="@+id/MyAppbar" android:layout_width="match_parent" android:layout_height="256dp" android:fitsSystemWindows="true"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapse_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" android:background="@color/material_deep_teal_500" android:fitsSystemWindows="true"> <ImageView android:id="@+id/bgheader" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:fitsSystemWindows="true" android:background="@drawable/screen" app:layout_collapseMode="pin" /> <android.support.v7.widget.Toolbar android:id="@+id/MyToolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="parallax" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:id="@+id/nested" android:layout_height="match_parent" android:layout_gravity="fill_vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/MyToolbar" android:background="?attr/colorPrimary" android:elevation="6dp" android:minHeight="?attr/actionBarSize" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> </LinearLayout> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout> Mainactivity layout activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.jeffy.viewpagerapp.MainActivity" tools:showIn="@layout/activity_main"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridView1" android:numColumns="2" android:gravity="center" android:columnWidth="100dp" android:stretchMode="columnWidth" android:layout_width="fill_parent" android:layout_height="fill_parent" > </GridView> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SAVE" android:id="@+id/button" /> </LinearLayout> </RelativeLayout> ``` Hope this would help someone... Click up button please if this helped you
To remove you can use this directly: ``` getSupportFragmentManager().beginTransaction().remove(fragment). commitAllowingStateLoss(); ``` `fragment` is the fragment you want to remove.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
Here's an alternative solution to this question. My adapter: ``` private class PagerAdapter extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener, TabListener { private List<Fragment> mFragments = new ArrayList<Fragment>(); private ViewPager mPager; private ActionBar mActionBar; private Fragment mPrimaryItem; public PagerAdapter(FragmentManager fm, ViewPager vp, ActionBar ab) { super(fm); mPager = vp; mPager.setAdapter(this); mPager.setOnPageChangeListener(this); mActionBar = ab; } public void addTab(PartListFragment frag) { mFragments.add(frag); mActionBar.addTab(mActionBar.newTab().setTabListener(this). setText(frag.getPartCategory())); } @Override public Fragment getItem(int position) { return mFragments.get(position); } @Override public int getCount() { return mFragments.size(); } /** (non-Javadoc) * @see android.support.v4.app.FragmentStatePagerAdapter#setPrimaryItem(android.view.ViewGroup, int, java.lang.Object) */ @Override public void setPrimaryItem(ViewGroup container, int position, Object object) { super.setPrimaryItem(container, position, object); mPrimaryItem = (Fragment) object; } /** (non-Javadoc) * @see android.support.v4.view.PagerAdapter#getItemPosition(java.lang.Object) */ @Override public int getItemPosition(Object object) { if (object == mPrimaryItem) { return POSITION_UNCHANGED; } return POSITION_NONE; } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { mPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int position) { mActionBar.setSelectedNavigationItem(position); } /** * This method removes the pages from ViewPager */ public void removePages() { mActionBar.removeAllTabs(); //call to ViewPage to remove the pages vp.removeAllViews(); mFragments.clear(); //make this to update the pager vp.setAdapter(null); vp.setAdapter(pagerAdapter); } } ``` Code to remove and add dynamically ``` //remove the pages. basically call to method removeAllViews from `ViewPager` pagerAdapter.removePages(); pagerAdapter.addPage(pass your fragment); ``` After the advice of Peri Hartman, it started to work after I set null do ViewPager adapter and put the adapter again after the views removed. Before this the page 0 doesnt showed its list contents. Thanks.
To remove you can use this directly: ``` getSupportFragmentManager().beginTransaction().remove(fragment). commitAllowingStateLoss(); ``` `fragment` is the fragment you want to remove.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
After figuring out which ViewPager methods are called by ViewPager and which are for other purposes, I came up with a solution. I present it here since I see a lot of people have struggled with this and I didn't see any other relevant answers. First, here's my adapter; hopefully comments within the code are sufficient: ``` public class MainPagerAdapter extends PagerAdapter { // This holds all the currently displayable views, in order from left to right. private ArrayList<View> views = new ArrayList<View>(); //----------------------------------------------------------------------------- // Used by ViewPager. "Object" represents the page; tell the ViewPager where the // page should be displayed, from left-to-right. If the page no longer exists, // return POSITION_NONE. @Override public int getItemPosition (Object object) { int index = views.indexOf (object); if (index == -1) return POSITION_NONE; else return index; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager needs a page to display; it is our job // to add the page to the container, which is normally the ViewPager itself. Since // all our pages are persistent, we simply retrieve it from our "views" ArrayList. @Override public Object instantiateItem (ViewGroup container, int position) { View v = views.get (position); container.addView (v); return v; } //----------------------------------------------------------------------------- // Used by ViewPager. Called when ViewPager no longer needs a page to display; it // is our job to remove the page from the container, which is normally the // ViewPager itself. Since all our pages are persistent, we do nothing to the // contents of our "views" ArrayList. @Override public void destroyItem (ViewGroup container, int position, Object object) { container.removeView (views.get (position)); } //----------------------------------------------------------------------------- // Used by ViewPager; can be used by app as well. // Returns the total number of pages that the ViewPage can display. This must // never be 0. @Override public int getCount () { return views.size(); } //----------------------------------------------------------------------------- // Used by ViewPager. @Override public boolean isViewFromObject (View view, Object object) { return view == object; } //----------------------------------------------------------------------------- // Add "view" to right end of "views". // Returns the position of the new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v) { return addView (v, views.size()); } //----------------------------------------------------------------------------- // Add "view" at "position" to "views". // Returns position of new view. // The app should call this to add pages; not used by ViewPager. public int addView (View v, int position) { views.add (position, v); return position; } //----------------------------------------------------------------------------- // Removes "view" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, View v) { return removeView (pager, views.indexOf (v)); } //----------------------------------------------------------------------------- // Removes the "view" at "position" from "views". // Retuns position of removed view. // The app should call this to remove pages; not used by ViewPager. public int removeView (ViewPager pager, int position) { // ViewPager doesn't have a delete method; the closest is to set the adapter // again. When doing so, it deletes all its views. Then we can delete the view // from from the adapter and finally set the adapter to the pager again. Note // that we set the adapter to null before removing the view from "views" - that's // because while ViewPager deletes all its views, it will call destroyItem which // will in turn cause a null pointer ref. pager.setAdapter (null); views.remove (position); pager.setAdapter (this); return position; } //----------------------------------------------------------------------------- // Returns the "view" at "position". // The app should call this to retrieve a view; not used by ViewPager. public View getView (int position) { return views.get (position); } // Other relevant methods: // finishUpdate - called by the ViewPager - we don't care about what pages the // pager is displaying so we don't use this method. } ``` And here's some snips of code showing how to use the adapter. ``` class MainActivity extends Activity { private ViewPager pager = null; private MainPagerAdapter pagerAdapter = null; //----------------------------------------------------------------------------- @Override public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView (R.layout.main_activity); ... do other initialization, such as create an ActionBar ... pagerAdapter = new MainPagerAdapter(); pager = (ViewPager) findViewById (R.id.view_pager); pager.setAdapter (pagerAdapter); // Create an initial view to display; must be a subclass of FrameLayout. LayoutInflater inflater = context.getLayoutInflater(); FrameLayout v0 = (FrameLayout) inflater.inflate (R.layout.one_of_my_page_layouts, null); pagerAdapter.addView (v0, 0); pagerAdapter.notifyDataSetChanged(); } //----------------------------------------------------------------------------- // Here's what the app should do to add a view to the ViewPager. public void addView (View newPage) { int pageIndex = pagerAdapter.addView (newPage); // You might want to make "newPage" the currently displayed page: pager.setCurrentItem (pageIndex, true); } //----------------------------------------------------------------------------- // Here's what the app should do to remove a view from the ViewPager. public void removeView (View defunctPage) { int pageIndex = pagerAdapter.removeView (pager, defunctPage); // You might want to choose what page to display, if the current page was "defunctPage". if (pageIndex == pagerAdapter.getCount()) pageIndex--; pager.setCurrentItem (pageIndex); } //----------------------------------------------------------------------------- // Here's what the app should do to get the currently displayed page. public View getCurrentPage () { return pagerAdapter.getView (pager.getCurrentItem()); } //----------------------------------------------------------------------------- // Here's what the app should do to set the currently displayed page. "pageToShow" must // currently be in the adapter, or this will crash. public void setCurrentPage (View pageToShow) { pager.setCurrentItem (pagerAdapter.getItemPosition (pageToShow), true); } } ``` Finally, you can use the following for your `activity_main.xml` layout: ``` <?xml version="1.0" encoding="utf-8"?> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" > </android.support.v4.view.ViewPager> ```
I was looking for simple solution to remove views from viewpager (no fragments) dynamically. So, if you have some info, that your pages belongs to, you can set it to View as tag. Just like that (adapter code): ``` @Override public Object instantiateItem(ViewGroup collection, int position) { ImageView iv = new ImageView(mContext); MediaMessage msg = mMessages.get(position); ... iv.setTag(media); return iv; } @Override public int getItemPosition (Object object) { View o = (View) object; int index = mMessages.indexOf(o.getTag()); if (index == -1) return POSITION_NONE; else return index; } ``` You just need remove your info from mMessages, and then call `notifyDataSetChanged()` for your adapter. Bad news there is no animation in this case.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
To remove you can use this directly: ``` getSupportFragmentManager().beginTransaction().remove(fragment). commitAllowingStateLoss(); ``` `fragment` is the fragment you want to remove.
I find a good solution for this issue, this solution can make it work and no need to recreate Fragments. My key point is: 1. **setup ViewPager every time you delete or add Tab(Fragment).** 2. **Override the getItemId method, return a specific id rather than position.** Source Code ``` package com.zq.testviewpager; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.ArrayList; import java.util.Arrays; /** * Created by z8888q@gmail.com on 2017/5/31. * Implement dynamic delete or add tab(TAB_C in this test code). */ public class MainActivity extends AppCompatActivity { private static final int TAB_A = 1001; private static final int TAB_B = 1002; private static final int TAB_C = 1003; private static final int TAB_D = 1004; private static final int TAB_E = 1005; private Tab[] tabsArray = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_C, "C"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs = new ArrayList<>(Arrays.asList(tabsArray)); private Tab[] tabsArray2 = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs2 = new ArrayList<>(Arrays.asList(tabsArray2)); /** * The {@link android.support.v4.view.PagerAdapter} that will provide * fragments for each of the sections. We use a * {@link FragmentPagerAdapter} derivative, which will keep every * loaded fragment in memory. If this becomes too memory intensive, it * may be best to switch to a * {@link android.support.v4.app.FragmentStatePagerAdapter}. */ private SectionsPagerAdapter mSectionsPagerAdapter; /** * The {@link ViewPager} that will host the section contents. */ private ViewPager mViewPager; private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; }else if (id == R.id.action_delete) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs.get(currentItemPosition); if(currentTab.id == TAB_C){ currentTab = mTabs.get(currentItemPosition == 0 ? currentItemPosition +1 : currentItemPosition - 1); } mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs2, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs2.indexOf(currentTab), false); return true; }else if (id == R.id.action_add) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs2.get(currentItemPosition); mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs.indexOf(currentTab), false); return true; }else return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; public PlaceholderFragment() { } /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("TestViewPager", "onCreate"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public void onDestroy() { super.onDestroy(); Log.e("TestViewPager", "onDestroy"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); TextView textView = (TextView) rootView.findViewById(R.id.section_label); textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); return rootView; } } /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ public class SectionsPagerAdapter extends FragmentPagerAdapter { ArrayList<Tab> tabs; public SectionsPagerAdapter(ArrayList<Tab> tabs, FragmentManager fm) { super(fm); this.tabs = tabs; } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). return PlaceholderFragment.newInstance(tabs.get(position).id); } @Override public int getCount() { return tabs.size(); } @Override public long getItemId(int position) { return tabs.get(position).id; } @Override public CharSequence getPageTitle(int position) { return tabs.get(position).title; } } private static class Tab { String title; public int id; Tab(int id, String title){ this.id = id; this.title = title; } @Override public boolean equals(Object obj) { if(obj instanceof Tab){ return ((Tab)obj).id == id; }else{ return false; } } } } ``` Code is at my [Github Gist](https://gist.github.com/z8888q/056ff15d7bfa5fff57985bf4f08e907b).
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
I've created a [custom PagerAdapters library](https://github.com/takaaki7/ArrayPagerAdapter) to change items in PagerAdapters dynamically. You can change items dynamically like following by using this library. ``` @Override protected void onCreate(Bundle savedInstanceState) { /** ... **/ adapter = new MyStatePagerAdapter(getSupportFragmentManager() , new String[]{"1", "2", "3"}); ((ViewPager)findViewById(R.id.view_pager)).setAdapter(adapter); adapter.add("4"); adapter.remove(0); } class MyPagerAdapter extends ArrayViewPagerAdapter<String> { public MyPagerAdapter(String[] data) { super(data); } @Override public View getView(LayoutInflater inflater, ViewGroup container, String item, int position) { View v = inflater.inflate(R.layout.item_page, container, false); ((TextView) v.findViewById(R.id.item_txt)).setText(item); return v; } } ``` Thils library also support pages created by Fragments.
To remove you can use this directly: ``` getSupportFragmentManager().beginTransaction().remove(fragment). commitAllowingStateLoss(); ``` `fragment` is the fragment you want to remove.
13,664,157
I am working on an Android project for my CS class where I need to enter mock coordinates. I want to specify a different layout file for orientation and portrait orientations. I have a `layout` folder and a `layout-land` folder in my `/res` folder. The xml file in the layout folder and the xml file in the layout-land folder are named exactly the same. I do NOT have `android:configChanges="orientation"` or `android:screenOrientation="portrait"` set for this specific activity - however, I do have it set for other activities. I am not implementing `onConfigurationChanged` in this activity either. Theoretically, the screen should change to the layout specified in `layout-land` when the orientation changes with these settings, correct? However, this is not the case. The layout stays the same. I attempted to force it to change by giving the landscape layout a different layout id, `android:id="@+layout/activity_mock_coor_land"`, then doing `setContentView(R.layout.activity_mock_coor_land)"`. However, it gave me an error with this stack trace: ``` AndroidRuntime(13964): FATAL EXCEPTION: main AndroidRuntime(13964): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mixd.grounds.tour/com.mixd.grounds.tour.MockCoor}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) AndroidRuntime(13964): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) AndroidRuntime(13964): at android.app.ActivityThread.access$2300(ActivityThread.java:125) AndroidRuntime(13964): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) AndroidRuntime(13964): at android.os.Handler.dispatchMessage(Handler.java:99) AndroidRuntime(13964): at android.os.Looper.loop(Looper.java:123) AndroidRuntime(13964): at android.app.ActivityThread.main(ActivityThread.java:4627) AndroidRuntime(13964): at java.lang.reflect.Method.invokeNative(Native Method) AndroidRuntime(13964): at java.lang.reflect.Method.invoke(Method.java:521) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) AndroidRuntime(13964): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) AndroidRuntime(13964): at dalvik.system.NativeStart.main(Native Method) AndroidRuntime(13964): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030009 type #0x12 is not valid AndroidRuntime(13964): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874) AndroidRuntime(13964): at android.content.res.Resources.getLayout(Resources.java:731) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:318) AndroidRuntime(13964): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) AndroidRuntime(13964): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) AndroidRuntime(13964): at android.app.Activity.setContentView(Activity.java:1647) AndroidRuntime(13964): at com.mixd.grounds.tour.MockCoor.onCreate(MockCoor.java:21) AndroidRuntime(13964): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) AndroidRuntime(13964): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) AndroidRuntime(13964): ... 11 more ``` I'm not really sure what it means. Can it not find my layout in `layout-land`? Can anyone help with this problem? EDIT: Manifest: > > `<manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="com.mixd.grounds.tour" > android:versionCode="1" > android:versionName="1.0" >` > > > ``` <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" android:required="true" /> <activity android:name=".SplashScreen" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MapsActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_maps" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MainActivity" android:configChanges="keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".Choice" android:label="@string/title_activity_choice" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockCoor" android:label="@string/title_activity_mock_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".MockActivity" android:label="@string/title_activity_mock" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".NextCoor" android:label="@string/title_activity_next_coor" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".HistoryButton" android:label="@string/title_activity_history_button" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name=".DisplayHistory" android:label="@string/title_activity_display_history" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> ``` > > `</manifest>` > > >
2012/12/01
[ "https://Stackoverflow.com/questions/13664157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1839623/" ]
I've created a [custom PagerAdapters library](https://github.com/takaaki7/ArrayPagerAdapter) to change items in PagerAdapters dynamically. You can change items dynamically like following by using this library. ``` @Override protected void onCreate(Bundle savedInstanceState) { /** ... **/ adapter = new MyStatePagerAdapter(getSupportFragmentManager() , new String[]{"1", "2", "3"}); ((ViewPager)findViewById(R.id.view_pager)).setAdapter(adapter); adapter.add("4"); adapter.remove(0); } class MyPagerAdapter extends ArrayViewPagerAdapter<String> { public MyPagerAdapter(String[] data) { super(data); } @Override public View getView(LayoutInflater inflater, ViewGroup container, String item, int position) { View v = inflater.inflate(R.layout.item_page, container, false); ((TextView) v.findViewById(R.id.item_txt)).setText(item); return v; } } ``` Thils library also support pages created by Fragments.
I find a good solution for this issue, this solution can make it work and no need to recreate Fragments. My key point is: 1. **setup ViewPager every time you delete or add Tab(Fragment).** 2. **Override the getItemId method, return a specific id rather than position.** Source Code ``` package com.zq.testviewpager; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.ArrayList; import java.util.Arrays; /** * Created by z8888q@gmail.com on 2017/5/31. * Implement dynamic delete or add tab(TAB_C in this test code). */ public class MainActivity extends AppCompatActivity { private static final int TAB_A = 1001; private static final int TAB_B = 1002; private static final int TAB_C = 1003; private static final int TAB_D = 1004; private static final int TAB_E = 1005; private Tab[] tabsArray = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_C, "C"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs = new ArrayList<>(Arrays.asList(tabsArray)); private Tab[] tabsArray2 = new Tab[]{new Tab(TAB_A, "A"),new Tab(TAB_B, "B"),new Tab(TAB_D, "D"),new Tab(TAB_E, "E")}; private ArrayList<Tab> mTabs2 = new ArrayList<>(Arrays.asList(tabsArray2)); /** * The {@link android.support.v4.view.PagerAdapter} that will provide * fragments for each of the sections. We use a * {@link FragmentPagerAdapter} derivative, which will keep every * loaded fragment in memory. If this becomes too memory intensive, it * may be best to switch to a * {@link android.support.v4.app.FragmentStatePagerAdapter}. */ private SectionsPagerAdapter mSectionsPagerAdapter; /** * The {@link ViewPager} that will host the section contents. */ private ViewPager mViewPager; private TabLayout tabLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; }else if (id == R.id.action_delete) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs.get(currentItemPosition); if(currentTab.id == TAB_C){ currentTab = mTabs.get(currentItemPosition == 0 ? currentItemPosition +1 : currentItemPosition - 1); } mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs2, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs2.indexOf(currentTab), false); return true; }else if (id == R.id.action_add) { int currentItemPosition = mViewPager.getCurrentItem(); Tab currentTab = mTabs2.get(currentItemPosition); mSectionsPagerAdapter = new SectionsPagerAdapter(mTabs, getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); tabLayout.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(mTabs.indexOf(currentTab), false); return true; }else return super.onOptionsItemSelected(item); } /** * A placeholder fragment containing a simple view. */ public static class PlaceholderFragment extends Fragment { /** * The fragment argument representing the section number for this * fragment. */ private static final String ARG_SECTION_NUMBER = "section_number"; public PlaceholderFragment() { } /** * Returns a new instance of this fragment for the given section * number. */ public static PlaceholderFragment newInstance(int sectionNumber) { PlaceholderFragment fragment = new PlaceholderFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("TestViewPager", "onCreate"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public void onDestroy() { super.onDestroy(); Log.e("TestViewPager", "onDestroy"+getArguments().getInt(ARG_SECTION_NUMBER)); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); TextView textView = (TextView) rootView.findViewById(R.id.section_label); textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER))); return rootView; } } /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ public class SectionsPagerAdapter extends FragmentPagerAdapter { ArrayList<Tab> tabs; public SectionsPagerAdapter(ArrayList<Tab> tabs, FragmentManager fm) { super(fm); this.tabs = tabs; } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). return PlaceholderFragment.newInstance(tabs.get(position).id); } @Override public int getCount() { return tabs.size(); } @Override public long getItemId(int position) { return tabs.get(position).id; } @Override public CharSequence getPageTitle(int position) { return tabs.get(position).title; } } private static class Tab { String title; public int id; Tab(int id, String title){ this.id = id; this.title = title; } @Override public boolean equals(Object obj) { if(obj instanceof Tab){ return ((Tab)obj).id == id; }else{ return false; } } } } ``` Code is at my [Github Gist](https://gist.github.com/z8888q/056ff15d7bfa5fff57985bf4f08e907b).
7,542,542
I've narrowed my problem area down to the function below. It's part of a userscript I'm writing. It works perfectly in Chrome, but doesn't work at all in Firefox/Greasemonkey. I've tinkered with it all day and have hit a brick wall. The only thing that makes sense is if JSON.parse isn't working right, which would make sense since Chrome is known to handle JSON.parse somewhat differently... but I know the JSON is perfectly formed! ``` function getTagline() { var jsonfile = new XMLHttpRequest(); jsonfile.open("GET", "http://example.com/somegood.json", true); jsonfile.onreadystatechange = function() { if (jsonfile.readyState == 4) { if (jsonfile.status == 200) { var taglines = JSON.parse(jsonfile.responseText); var choose = Math.floor(Math.random() * taglines.length); var tagline = document.createTextNode(taglines[choose].metais); insertTagline(tagline); } } }; jsonfile.send(null); } ``` Any ideas?
2011/09/24
[ "https://Stackoverflow.com/questions/7542542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/963104/" ]
That is, [AFAIK](http://en.wiktionary.org/wiki/AFAIK), not possible due to security reasons. The keyword is [cross-site scripting (XSS)](http://en.wikipedia.org/wiki/Cross-site_scripting).
The best option would be to use the iFrame example from the link your provided. You can now add iFrames to your Facebook Page ( not individual user profiles ) using this process: <http://developers.facebook.com/blog/post/462/>
41,356,669
I have a collection : ``` { _id : xxx, children : [ { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] } ] }, { _id : xxx, children : [ { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] } ] }, { _id : xxx, children : [ { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] } ] }, { _id : xxx, children : [ { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] }, { childrenOfChildren : [ { price : xxx }, { price : xxx }, { price : xxx } ] } ] } ``` Every entry has an array named **children**. And Every entry in children has an array named **childrenOfChildren**. And every entry in childrenOfChildren has an attribute named **price**. I wanna get maximum value of price in this overall collection. How can I achieve this? Please help me!
2016/12/28
[ "https://Stackoverflow.com/questions/41356669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5436005/" ]
you can do this using $unwind and $group. ``` db.collection.aggregate([ { $unwind:"$children" }, { $unwind:"$children.childrenOfChildren" }, { $group:{ _id:null, maxPrice:{ $max:"$children.childrenOfChildren.price" } } } ]) ``` output: ``` { "_id" : null, "maxPrice" : 110 } ``` try it online: [mongoplayground.net/p/sBTclni0YSw](https://mongoplayground.net/p/sBTclni0YSw)
you can get maximum price from overall collection by using `aggregate` query with `$unwind` and `$group`. can try this query: ``` db.getCollection('collectionName').aggregate([ {$unwind: "$children"}, {$unwind: "$children.childrenOfChildren"}, {$group:{_id: null, price:{$max: "$children.childrenOfChildren.price"}}} ]) ```
1,440
I'm wondering if this should be a single tag. However, if we do keep them as separate tags, how do we disambiguate? [natural-language](https://ai.stackexchange.com/questions/tagged/natural-language) [natural-language-processing](https://ai.stackexchange.com/questions/tagged/natural-language-processing)
2018/10/03
[ "https://ai.meta.stackexchange.com/questions/1440", "https://ai.meta.stackexchange.com", "https://ai.meta.stackexchange.com/users/1671/" ]
It looks to me like they are both used for similar questions, and based on the current Tag Info for the two tags they don't really appear to be different either. So, based on current tag usage, I'd argue that they should be combined into a single tag (which, in my opinion, should be `natural-language-processing` because that's the full term that everyone in the field uses in my experience). I suppose that, in theory, `natural-language` could refer to something else than NLP... like, it could be for questions about language itself, rather than questions about processing (generating and/or understanding) language. I have a very difficult time imagining any such questions would actually be on-topic for AI though.
There is a key difference between the two terms. Whether this finer level of granularity is useful in the tags, I have no opinion. Natural language is concerned with the general idea of conveying ideas via vocalization and the comprehension of the idea by a listener. Natural language processing sounds more well defined, but it is actually poorly defined and the definitions in the literature are scattered between these two extremes: 1. Parsing text into linguistic structures. 2. Linguistic processing components in chat-bots designed to replace human experts. What is included in NLP? * Talking? * Generating text? * Generating linguistic associations? * Parsing text? * Hearing? * Listening? * Dialog? * Topic detection? * Cognition? * Story invocation? — See Schank. * Translation? Depends on who is teaching and when. I don't even see any consistency between the same person's view of NLP over time. If addressing the terms literally, natural language is simply the field of linguistics minus the addition of formal languages. NLP would then become the action that occurs when some system deals with natural language at either its input, its output, or both. I saw those two tags earlier today. I don't have a recommendation as to whether to combine them or leave them alone.
1,440
I'm wondering if this should be a single tag. However, if we do keep them as separate tags, how do we disambiguate? [natural-language](https://ai.stackexchange.com/questions/tagged/natural-language) [natural-language-processing](https://ai.stackexchange.com/questions/tagged/natural-language-processing)
2018/10/03
[ "https://ai.meta.stackexchange.com/questions/1440", "https://ai.meta.stackexchange.com", "https://ai.meta.stackexchange.com/users/1671/" ]
It looks to me like they are both used for similar questions, and based on the current Tag Info for the two tags they don't really appear to be different either. So, based on current tag usage, I'd argue that they should be combined into a single tag (which, in my opinion, should be `natural-language-processing` because that's the full term that everyone in the field uses in my experience). I suppose that, in theory, `natural-language` could refer to something else than NLP... like, it could be for questions about language itself, rather than questions about processing (generating and/or understanding) language. I have a very difficult time imagining any such questions would actually be on-topic for AI though.
Natural language *by itself* (that is, without considering computation-related aspects) has little to do with AI. In AI, we want to do NLP, which can be based on natural language, but the tag [natural-language-processing](https://ai.stackexchange.com/questions/tagged/natural-language-processing "show questions tagged 'natural-language-processing'") or [nlp](https://ai.stackexchange.com/questions/tagged/nlp "show questions tagged 'nlp'") should also include these related discussions or questions. So, the tag [natural-language](https://ai.stackexchange.com/questions/tagged/natural-language "show questions tagged 'natural-language'") should not really exist.
1,440
I'm wondering if this should be a single tag. However, if we do keep them as separate tags, how do we disambiguate? [natural-language](https://ai.stackexchange.com/questions/tagged/natural-language) [natural-language-processing](https://ai.stackexchange.com/questions/tagged/natural-language-processing)
2018/10/03
[ "https://ai.meta.stackexchange.com/questions/1440", "https://ai.meta.stackexchange.com", "https://ai.meta.stackexchange.com/users/1671/" ]
Natural language *by itself* (that is, without considering computation-related aspects) has little to do with AI. In AI, we want to do NLP, which can be based on natural language, but the tag [natural-language-processing](https://ai.stackexchange.com/questions/tagged/natural-language-processing "show questions tagged 'natural-language-processing'") or [nlp](https://ai.stackexchange.com/questions/tagged/nlp "show questions tagged 'nlp'") should also include these related discussions or questions. So, the tag [natural-language](https://ai.stackexchange.com/questions/tagged/natural-language "show questions tagged 'natural-language'") should not really exist.
There is a key difference between the two terms. Whether this finer level of granularity is useful in the tags, I have no opinion. Natural language is concerned with the general idea of conveying ideas via vocalization and the comprehension of the idea by a listener. Natural language processing sounds more well defined, but it is actually poorly defined and the definitions in the literature are scattered between these two extremes: 1. Parsing text into linguistic structures. 2. Linguistic processing components in chat-bots designed to replace human experts. What is included in NLP? * Talking? * Generating text? * Generating linguistic associations? * Parsing text? * Hearing? * Listening? * Dialog? * Topic detection? * Cognition? * Story invocation? — See Schank. * Translation? Depends on who is teaching and when. I don't even see any consistency between the same person's view of NLP over time. If addressing the terms literally, natural language is simply the field of linguistics minus the addition of formal languages. NLP would then become the action that occurs when some system deals with natural language at either its input, its output, or both. I saw those two tags earlier today. I don't have a recommendation as to whether to combine them or leave them alone.
64,093
The words :- > > τουτο εστιν το σωμα μου το υπερ υμων διδομενον [Stephanus 1550/Elzevir 1624] > > > this is my body which is given for you [KJV 1769 Luke 22:19] > > > and, particularly : > > *hoc est meum corpus* [Vulgate - Jerome 382/Clementine 1592] > > > this is my body > > > were spoken as Jesus stood before the disciples, his hands holding out bread to them. 1. How then, at that instant, could bread have been - literally - his own real body. ? 2. It was not - literally - true that the bread was 'given' (sacrificially) at that instant of time. It is a figure of speech. It is the way concepts are expressed in language. 3. And if Jesus requires > > this do in remembrance of me [KJV 1769 Luke 22:19] > > > then it is a *memorial* of what was about to occur. *Not a physical re-enactment*. It is the faculty of memory that he wishes to be engaged, not the process of digestion. --- How are these *particular questions* answered by those who suppose a literal meaning to *hoc est meum corpus* ?
2018/06/14
[ "https://christianity.stackexchange.com/questions/64093", "https://christianity.stackexchange.com", "https://christianity.stackexchange.com/users/38350/" ]
I will attempt to answer your questions, but I think we need to start with a detour into what the Catholic doctrine of the Eucharist actually *is*. You use a couple of words that lead me to think you misunderstand the doctrine: "digestion" and "literally ... real". The Catholic doctrine is not that the Eucharist is Christ's body in the same way that you could get a sharp knife and cut a bit of him off. (This isn't *The Merchant of Venice*!) The doctrine is that > > In the most blessed sacrament of the Eucharist "the body and blood, together with the soul and divinity, of our Lord Jesus Christ and, therefore, the whole Christ is truly, really, and substantially contained. ([Catechism of the Catholic Church, ¶1374](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1374)) > > > Similarly, we can read Thomas Aquinas, who answers the question "Whether Christ's body is in this sacrament as in a place?" > > Hence it remains that Christ's body is not in this sacrament as in a place, but after the manner of substance, that is to say, in that way in which substance is contained by dimensions; because the substance of Christ's body succeeds the substance of bread in this sacrament: hence as the substance of bread was not locally under its dimensions, but after the manner of substance, so neither is the substance of Christ's body. (*Summa Theologia* III, 76.5) > > > That is to say, Christ's presence in the Eucharistic species is not *restricted* to the Eucharistic species. It isn't "a bit of Christ". It is just "Christ". I think that answers your first question: "How then, at that instant, could bread have been - literally - his own real body?" You next say that the bread was not "given" at that moment of time. Well, yes: the sacrifice in question is the sacrifice of Christ on the Cross, of which the Last Supper is part and of which the Eucharist is a re-presentation. Again, from the Catechism: > > The sacrifice of Christ and the sacrifice of the Eucharist are one single sacrifice ([Catechism of the Catholic Church, ¶1367](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1367)) > > > Or, from *Sacrosanctum Concilium*: > > At the Last Supper, on the night when He was betrayed, our Saviour instituted the eucharistic sacrifice of His Body and Blood. He did this in order to perpetuate the sacrifice of the Cross. (*[Sacrosanctum Concilium](http://www.vatican.va/archive/hist_councils/ii_vatican_council/documents/vat-ii_const_19631204_sacrosanctum-concilium_en.html)*, ¶47) > > > The Eucharist is intimately related to the Cross: they are one sacrifice. Finally, you talk about the question of a "memorial", which you contrast to a "physical re-enactment". The Catholic doctrine is that "memorial" means a lot more than a simple "remembering". Really it's worth reading the entire section of the Catechism entitled "The sacrificial memorial of Christ and of his Body, the Church". Here are a few key parts: > > The Eucharist is the memorial of Christ's Passover, the making present and the sacramental offering of his unique sacrifice, in the liturgy of the Church which is his Body. ... > > > In the sense of Sacred Scripture the memorial is not merely the recollection of past events but the proclamation of the mighty works wrought by God for men. In the liturgical celebration of these events, they become in a certain way present and real. This is how Israel understands its liberation from Egypt: every time Passover is celebrated, the Exodus events are made present to the memory of believers so that they may conform their lives to them. > > > In the New Testament, the memorial takes on new meaning. When the Church celebrates the Eucharist, she commemorates Christ's Passover, and it is made present the sacrifice Christ offered once for all on the cross remains ever present. ([Catechism of the Catholic Church, ¶¶1362ff](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1362)) > > > So the Catholic view is that a memorial is a much richer thing than you suggest. The Eucharist is about presence, memorial, sacrifice, communion, and a whole host of other themes.
How does Roman Catholicism justify a literal meaning of 'Hoc est meum corpus'? hoc est meum corpus [Vulgate - Jerome 382/Clementine 1592] this is my body Biblically it's comes from the lips of Jesus Christ... Your specific question: 1.How then, at that instant, could bread have been - literally - his own real body. ? Answer : CCC1333 At the heart of the Eucharistic celebration are the bread and wine that, by the words of Christ and the invocation of the Holy Spirit, become Christ's Body and Blood. Faithful to the Lord's command the Church continues to do, in his memory and until his glorious return, what he did on the eve of his Passion: "He took bread. . . ." "He took the cup filled with wine. . . ." The signs of bread and wine become, in a way surpassing understanding, the Body and Blood of Christ; they continue also to signify the goodness of creation. Thus in the Offertory we give thanks to the Creator for bread and wine,154 fruit of the "work of human hands," but above all as "fruit of the earth" and "of the vine" - gifts of the Creator. The Church sees in the gesture of the king-priest Melchizedek, who "brought out bread and wine," a prefiguring of her own offering.155 Biblically it's comes from the lips of Jesus Christ... T"....his bread is my flesh, which I will give for the life of the world.” (John6:51) From the very word of Jesus Christ: " And he took bread, and when he had given thanks he broke it and gave it to them, saying, "This is my body which is given for you. Do this in remembrance of me." And likewise the cup after supper, saying, "This cup which is poured out for you is the New Covenant in my blood."(Matthew26:26-27) Now the BIG QUESTION that your trying to point is if the Transubstantiation occurs during the Last Suffer... Venerable Arch. Sheen said the Last Supper and the Calvary are the same. One is the unbloody sacrifice instituted for all of us and the other is the bloody sacrifice in Calvary At the Foot of the Cross. The Priest and the offered sacrificed are one and the same Jesus Christ. When Jesus said to the Apostles" what I have done, Do this in Remembrace of Me".Venerable Sheen said Jesus empowered the Apostles to celebrate the Holy Sacrifice with a vision of the actual sacrifice at Calvary. CCC1333 teaches the an ordained priest invoking the Holy Spirit turns the bread & wine in real flesh and blood...Then if this is our faith, How can we doubts if Jesus is the one who said it in the Last Supper Himself. Now, do we believe that the bread & wine at the Last Suffer become the true flesh and blood of Jesus? If we have faith in the words of Jesus that it is His flesh & blood, then it is really true by virtue of our living faith in Him. As God said "so My word that proceeds from My mouth will not return to Me empty, but it will accomplish what I please, and it will prosper where I send it. (Isaiah55:11) Other Supporting views: To give light on the issue...let's hear from the Jewish Bible Scholar talking on the Passover meal from the point of view of the Old Testament. The significant observation was Jesus did not drink the final cup of wine which is customary for the Jews in celebrating the Passover meal...so based on the Jewish customs the Passover Meal Jesus by not drinking the final cup of wine it is not yet finished, it is incomplete... This is affirmed in the Garden of Gethsemane where Jesus said "... “My Father, if it is possible, let this cup pass from Me. Yet not as I will, but as You will.” (Jesus still not drinking the wine) The Holy Sacrifice was finished at Calvary AT THE FOOT OF THE CROSS, after Jesus had drank the wine. John 19:28-30 King James Version (KJV) 28 After this, Jesus knowing that all things were now accomplished, that the scripture might be fulfilled, saith, I thirst. 29 Now there was set a vessel full of vinegar: and they filled a spunge with vinegar, and put it upon hyssop, and put it to his mouth. 30 When Jesus therefore had received the vinegar, he said, "IT IS FINISHED" and he bowed his head, and gave up the ghost. The whole and complete sacrifice was now offered. Dr. Brant Pitre shines fresh light on the Last Supper by looking at it through Jewish eyes. <https://www.youtube.com/watch?v=hjfHX046pLc> What was Jesus' purpose in instituting the Eucharist during the feast of Passover? And most important of all, what did Jesus mean when he said, "This is my body... This is my blood"? <https://www.youtube.com/watch?v=MsEKqG7hric> www.therealpresence.org "We are to believe that the Eucharist began in the womb of the Virgin Mary; that the flesh which the Son of God received from His Mother at the Incarnation is the same flesh into which He changed bread at the Last Supper; that the blood He received from His Mother is the same blood into which He changed wine at the Last Supper. Had she not given Him His flesh and blood there could not be a Eucharist." In closing, I will give a mystery of the Holy Eucharist when the First Mass was celebrated in the Upper Room... The Holy Eucharist is the body,blood,soul & divinity of our Glorified Resurrected Jesus Christ sacramentally instituted for us to transform our flesh & blood into intimate union/oneness with Jesus Christ eternally. Now the Mystery in the Upper Room is... what happen when an Immaculate Body (Flesh & Blood) of the Theotokos received the Holy Eucharist? Did She received a Transformation similar to the Resurrected Glorified Body of Jesus Christ?...Did the Theotokos transformed to Glorified Body that is worthy to enter the Kingdom of God even while still alive here on earth?... This is the Mystery on Infinite Mystical Union of the the Holy Spirit to Her Spouse/Advocate who became the Spirit of Truth...(but I wont expound it here) This is the POWER OF THE HOLY EUCHARIST and it's transforming power experienced by the Theotokos in Her Immaculate Body!(A Mystery worth discovering...) Godbless!. S&IHMMP4us.Amen
64,093
The words :- > > τουτο εστιν το σωμα μου το υπερ υμων διδομενον [Stephanus 1550/Elzevir 1624] > > > this is my body which is given for you [KJV 1769 Luke 22:19] > > > and, particularly : > > *hoc est meum corpus* [Vulgate - Jerome 382/Clementine 1592] > > > this is my body > > > were spoken as Jesus stood before the disciples, his hands holding out bread to them. 1. How then, at that instant, could bread have been - literally - his own real body. ? 2. It was not - literally - true that the bread was 'given' (sacrificially) at that instant of time. It is a figure of speech. It is the way concepts are expressed in language. 3. And if Jesus requires > > this do in remembrance of me [KJV 1769 Luke 22:19] > > > then it is a *memorial* of what was about to occur. *Not a physical re-enactment*. It is the faculty of memory that he wishes to be engaged, not the process of digestion. --- How are these *particular questions* answered by those who suppose a literal meaning to *hoc est meum corpus* ?
2018/06/14
[ "https://christianity.stackexchange.com/questions/64093", "https://christianity.stackexchange.com", "https://christianity.stackexchange.com/users/38350/" ]
I will attempt to answer your questions, but I think we need to start with a detour into what the Catholic doctrine of the Eucharist actually *is*. You use a couple of words that lead me to think you misunderstand the doctrine: "digestion" and "literally ... real". The Catholic doctrine is not that the Eucharist is Christ's body in the same way that you could get a sharp knife and cut a bit of him off. (This isn't *The Merchant of Venice*!) The doctrine is that > > In the most blessed sacrament of the Eucharist "the body and blood, together with the soul and divinity, of our Lord Jesus Christ and, therefore, the whole Christ is truly, really, and substantially contained. ([Catechism of the Catholic Church, ¶1374](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1374)) > > > Similarly, we can read Thomas Aquinas, who answers the question "Whether Christ's body is in this sacrament as in a place?" > > Hence it remains that Christ's body is not in this sacrament as in a place, but after the manner of substance, that is to say, in that way in which substance is contained by dimensions; because the substance of Christ's body succeeds the substance of bread in this sacrament: hence as the substance of bread was not locally under its dimensions, but after the manner of substance, so neither is the substance of Christ's body. (*Summa Theologia* III, 76.5) > > > That is to say, Christ's presence in the Eucharistic species is not *restricted* to the Eucharistic species. It isn't "a bit of Christ". It is just "Christ". I think that answers your first question: "How then, at that instant, could bread have been - literally - his own real body?" You next say that the bread was not "given" at that moment of time. Well, yes: the sacrifice in question is the sacrifice of Christ on the Cross, of which the Last Supper is part and of which the Eucharist is a re-presentation. Again, from the Catechism: > > The sacrifice of Christ and the sacrifice of the Eucharist are one single sacrifice ([Catechism of the Catholic Church, ¶1367](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1367)) > > > Or, from *Sacrosanctum Concilium*: > > At the Last Supper, on the night when He was betrayed, our Saviour instituted the eucharistic sacrifice of His Body and Blood. He did this in order to perpetuate the sacrifice of the Cross. (*[Sacrosanctum Concilium](http://www.vatican.va/archive/hist_councils/ii_vatican_council/documents/vat-ii_const_19631204_sacrosanctum-concilium_en.html)*, ¶47) > > > The Eucharist is intimately related to the Cross: they are one sacrifice. Finally, you talk about the question of a "memorial", which you contrast to a "physical re-enactment". The Catholic doctrine is that "memorial" means a lot more than a simple "remembering". Really it's worth reading the entire section of the Catechism entitled "The sacrificial memorial of Christ and of his Body, the Church". Here are a few key parts: > > The Eucharist is the memorial of Christ's Passover, the making present and the sacramental offering of his unique sacrifice, in the liturgy of the Church which is his Body. ... > > > In the sense of Sacred Scripture the memorial is not merely the recollection of past events but the proclamation of the mighty works wrought by God for men. In the liturgical celebration of these events, they become in a certain way present and real. This is how Israel understands its liberation from Egypt: every time Passover is celebrated, the Exodus events are made present to the memory of believers so that they may conform their lives to them. > > > In the New Testament, the memorial takes on new meaning. When the Church celebrates the Eucharist, she commemorates Christ's Passover, and it is made present the sacrifice Christ offered once for all on the cross remains ever present. ([Catechism of the Catholic Church, ¶¶1362ff](http://www.vatican.va/archive/ccc_css/archive/catechism/p2s2c1a3.htm#1362)) > > > So the Catholic view is that a memorial is a much richer thing than you suggest. The Eucharist is about presence, memorial, sacrifice, communion, and a whole host of other themes.
It's literal because Jesus Himself says so in [John 6:56](http://drbo.org/x/d?b=drl&bk=50&ch=6&l=56-#x): > > For my flesh is meat indeed: and my blood is drink indeed. > > >
64,093
The words :- > > τουτο εστιν το σωμα μου το υπερ υμων διδομενον [Stephanus 1550/Elzevir 1624] > > > this is my body which is given for you [KJV 1769 Luke 22:19] > > > and, particularly : > > *hoc est meum corpus* [Vulgate - Jerome 382/Clementine 1592] > > > this is my body > > > were spoken as Jesus stood before the disciples, his hands holding out bread to them. 1. How then, at that instant, could bread have been - literally - his own real body. ? 2. It was not - literally - true that the bread was 'given' (sacrificially) at that instant of time. It is a figure of speech. It is the way concepts are expressed in language. 3. And if Jesus requires > > this do in remembrance of me [KJV 1769 Luke 22:19] > > > then it is a *memorial* of what was about to occur. *Not a physical re-enactment*. It is the faculty of memory that he wishes to be engaged, not the process of digestion. --- How are these *particular questions* answered by those who suppose a literal meaning to *hoc est meum corpus* ?
2018/06/14
[ "https://christianity.stackexchange.com/questions/64093", "https://christianity.stackexchange.com", "https://christianity.stackexchange.com/users/38350/" ]
It's literal because Jesus Himself says so in [John 6:56](http://drbo.org/x/d?b=drl&bk=50&ch=6&l=56-#x): > > For my flesh is meat indeed: and my blood is drink indeed. > > >
How does Roman Catholicism justify a literal meaning of 'Hoc est meum corpus'? hoc est meum corpus [Vulgate - Jerome 382/Clementine 1592] this is my body Biblically it's comes from the lips of Jesus Christ... Your specific question: 1.How then, at that instant, could bread have been - literally - his own real body. ? Answer : CCC1333 At the heart of the Eucharistic celebration are the bread and wine that, by the words of Christ and the invocation of the Holy Spirit, become Christ's Body and Blood. Faithful to the Lord's command the Church continues to do, in his memory and until his glorious return, what he did on the eve of his Passion: "He took bread. . . ." "He took the cup filled with wine. . . ." The signs of bread and wine become, in a way surpassing understanding, the Body and Blood of Christ; they continue also to signify the goodness of creation. Thus in the Offertory we give thanks to the Creator for bread and wine,154 fruit of the "work of human hands," but above all as "fruit of the earth" and "of the vine" - gifts of the Creator. The Church sees in the gesture of the king-priest Melchizedek, who "brought out bread and wine," a prefiguring of her own offering.155 Biblically it's comes from the lips of Jesus Christ... T"....his bread is my flesh, which I will give for the life of the world.” (John6:51) From the very word of Jesus Christ: " And he took bread, and when he had given thanks he broke it and gave it to them, saying, "This is my body which is given for you. Do this in remembrance of me." And likewise the cup after supper, saying, "This cup which is poured out for you is the New Covenant in my blood."(Matthew26:26-27) Now the BIG QUESTION that your trying to point is if the Transubstantiation occurs during the Last Suffer... Venerable Arch. Sheen said the Last Supper and the Calvary are the same. One is the unbloody sacrifice instituted for all of us and the other is the bloody sacrifice in Calvary At the Foot of the Cross. The Priest and the offered sacrificed are one and the same Jesus Christ. When Jesus said to the Apostles" what I have done, Do this in Remembrace of Me".Venerable Sheen said Jesus empowered the Apostles to celebrate the Holy Sacrifice with a vision of the actual sacrifice at Calvary. CCC1333 teaches the an ordained priest invoking the Holy Spirit turns the bread & wine in real flesh and blood...Then if this is our faith, How can we doubts if Jesus is the one who said it in the Last Supper Himself. Now, do we believe that the bread & wine at the Last Suffer become the true flesh and blood of Jesus? If we have faith in the words of Jesus that it is His flesh & blood, then it is really true by virtue of our living faith in Him. As God said "so My word that proceeds from My mouth will not return to Me empty, but it will accomplish what I please, and it will prosper where I send it. (Isaiah55:11) Other Supporting views: To give light on the issue...let's hear from the Jewish Bible Scholar talking on the Passover meal from the point of view of the Old Testament. The significant observation was Jesus did not drink the final cup of wine which is customary for the Jews in celebrating the Passover meal...so based on the Jewish customs the Passover Meal Jesus by not drinking the final cup of wine it is not yet finished, it is incomplete... This is affirmed in the Garden of Gethsemane where Jesus said "... “My Father, if it is possible, let this cup pass from Me. Yet not as I will, but as You will.” (Jesus still not drinking the wine) The Holy Sacrifice was finished at Calvary AT THE FOOT OF THE CROSS, after Jesus had drank the wine. John 19:28-30 King James Version (KJV) 28 After this, Jesus knowing that all things were now accomplished, that the scripture might be fulfilled, saith, I thirst. 29 Now there was set a vessel full of vinegar: and they filled a spunge with vinegar, and put it upon hyssop, and put it to his mouth. 30 When Jesus therefore had received the vinegar, he said, "IT IS FINISHED" and he bowed his head, and gave up the ghost. The whole and complete sacrifice was now offered. Dr. Brant Pitre shines fresh light on the Last Supper by looking at it through Jewish eyes. <https://www.youtube.com/watch?v=hjfHX046pLc> What was Jesus' purpose in instituting the Eucharist during the feast of Passover? And most important of all, what did Jesus mean when he said, "This is my body... This is my blood"? <https://www.youtube.com/watch?v=MsEKqG7hric> www.therealpresence.org "We are to believe that the Eucharist began in the womb of the Virgin Mary; that the flesh which the Son of God received from His Mother at the Incarnation is the same flesh into which He changed bread at the Last Supper; that the blood He received from His Mother is the same blood into which He changed wine at the Last Supper. Had she not given Him His flesh and blood there could not be a Eucharist." In closing, I will give a mystery of the Holy Eucharist when the First Mass was celebrated in the Upper Room... The Holy Eucharist is the body,blood,soul & divinity of our Glorified Resurrected Jesus Christ sacramentally instituted for us to transform our flesh & blood into intimate union/oneness with Jesus Christ eternally. Now the Mystery in the Upper Room is... what happen when an Immaculate Body (Flesh & Blood) of the Theotokos received the Holy Eucharist? Did She received a Transformation similar to the Resurrected Glorified Body of Jesus Christ?...Did the Theotokos transformed to Glorified Body that is worthy to enter the Kingdom of God even while still alive here on earth?... This is the Mystery on Infinite Mystical Union of the the Holy Spirit to Her Spouse/Advocate who became the Spirit of Truth...(but I wont expound it here) This is the POWER OF THE HOLY EUCHARIST and it's transforming power experienced by the Theotokos in Her Immaculate Body!(A Mystery worth discovering...) Godbless!. S&IHMMP4us.Amen
69,881,150
I have a string like `23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2 + blablabla`. What I would like to do is to split up the string by `+`, yet in SPK section there is a L+R that would interrupt the process. Is there any REGEX that could achieve what I want? In result should be: ``` 23DGERA@SPK_20W L+R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` and now what i always get: ``` 23DGERA@SPK_20W L R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` I'm using Javascript `.split('+')` by now. Any help will be appretiated.
2021/11/08
[ "https://Stackoverflow.com/questions/69881150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16898096/" ]
You can use a matching regex solution: ```js text.match(/(?:L\+R|[^+])+/g) ``` See the [regex demo](https://regex101.com/r/m2XoxV/2/). *Details*: * `(?:` - start of a non-capturing group: + `L\+R` - `L+R` string + `|` - or + `[^+]` - any char other than `+` * `)+` - end of the group, one or more occurrences. See the JavaScript demo: ```js var text = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2'; console.log(text.match(/(?:L\+R|[^+])+/g)); ``` *ECMAScript 2018+ compliant solution* In case you want to migrate to a more modern ECMAScript flavor, you can use ```js text.split(/\+(?<!L\+(?=R))/) ``` This will match a `+` that is not part of an `L+R` string. ```js const text = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2'; console.log(text.split(/\+(?<!L\+(?=R))/)); ``` See the [regex demo](https://regex101.com/r/m2XoxV/3).
The string looks like a list of parts each with a quantity e.g. `@1`. You can use that to identify the correct `+` characters to split on. Using a look-behind containing `@\d+` -> `(?<=@\d+)` followed by the character you want to match (escaped because `+` has a special meaning) gives: ``` (?<=@\d+)\+ ``` Using this in code we also need specify the `g` modifier to match all instances instead of just the first one. ```js const str = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2' const items = str.split(/(?<=@\d+)\+/g); console.log(items); ```
69,881,150
I have a string like `23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2 + blablabla`. What I would like to do is to split up the string by `+`, yet in SPK section there is a L+R that would interrupt the process. Is there any REGEX that could achieve what I want? In result should be: ``` 23DGERA@SPK_20W L+R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` and now what i always get: ``` 23DGERA@SPK_20W L R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` I'm using Javascript `.split('+')` by now. Any help will be appretiated.
2021/11/08
[ "https://Stackoverflow.com/questions/69881150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16898096/" ]
You can use a matching regex solution: ```js text.match(/(?:L\+R|[^+])+/g) ``` See the [regex demo](https://regex101.com/r/m2XoxV/2/). *Details*: * `(?:` - start of a non-capturing group: + `L\+R` - `L+R` string + `|` - or + `[^+]` - any char other than `+` * `)+` - end of the group, one or more occurrences. See the JavaScript demo: ```js var text = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2'; console.log(text.match(/(?:L\+R|[^+])+/g)); ``` *ECMAScript 2018+ compliant solution* In case you want to migrate to a more modern ECMAScript flavor, you can use ```js text.split(/\+(?<!L\+(?=R))/) ``` This will match a `+` that is not part of an `L+R` string. ```js const text = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2'; console.log(text.split(/\+(?<!L\+(?=R))/)); ``` See the [regex demo](https://regex101.com/r/m2XoxV/3).
Instead of splitting on a `+` you could match the format in the example data. First match a part containing a single @, and then match till the first occurrence of `@` followed by a digit. **Note** that the second match will be `342HSHC@CPU_8PIN INTEL_TEST!@1` instead of `342HSHC@CPU_8PIN INTEL_TEST!@2` ``` \w+@\w+ [^@]*@\d\b ``` The pattern matches: * `\w+@\w+` Match 1+ word characters, `@` and at 1+ word characters * `[^@]*@` Match a space, optional chars other than `@`, then match `@` * `\d\b` Match a digit and a word boundary to prevent a partial match [Regex demo](https://regex101.com/r/HSXB7f/1) ```js const s = "23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2 + blablabla"; const regex = /\w+@\w+ [^@]*@\d\b/g; console.log(s.match(regex)); ```
69,881,150
I have a string like `23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2 + blablabla`. What I would like to do is to split up the string by `+`, yet in SPK section there is a L+R that would interrupt the process. Is there any REGEX that could achieve what I want? In result should be: ``` 23DGERA@SPK_20W L+R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` and now what i always get: ``` 23DGERA@SPK_20W L R FA-2@1 342HSHC@CPU_8PIN INTEL_TEST!@2 2356GHMX@SSD_256G MICRON_CONTENT@2 ``` I'm using Javascript `.split('+')` by now. Any help will be appretiated.
2021/11/08
[ "https://Stackoverflow.com/questions/69881150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16898096/" ]
Instead of splitting on a `+` you could match the format in the example data. First match a part containing a single @, and then match till the first occurrence of `@` followed by a digit. **Note** that the second match will be `342HSHC@CPU_8PIN INTEL_TEST!@1` instead of `342HSHC@CPU_8PIN INTEL_TEST!@2` ``` \w+@\w+ [^@]*@\d\b ``` The pattern matches: * `\w+@\w+` Match 1+ word characters, `@` and at 1+ word characters * `[^@]*@` Match a space, optional chars other than `@`, then match `@` * `\d\b` Match a digit and a word boundary to prevent a partial match [Regex demo](https://regex101.com/r/HSXB7f/1) ```js const s = "23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2 + blablabla"; const regex = /\w+@\w+ [^@]*@\d\b/g; console.log(s.match(regex)); ```
The string looks like a list of parts each with a quantity e.g. `@1`. You can use that to identify the correct `+` characters to split on. Using a look-behind containing `@\d+` -> `(?<=@\d+)` followed by the character you want to match (escaped because `+` has a special meaning) gives: ``` (?<=@\d+)\+ ``` Using this in code we also need specify the `g` modifier to match all instances instead of just the first one. ```js const str = '23DGERA@SPK_20W L+R FA-2@1+342HSHC@CPU_8PIN INTEL_TEST!@1+2356GHMX@SSD_256G MICRON_CONTENT@2' const items = str.split(/(?<=@\d+)\+/g); console.log(items); ```
3,214,023
I am attempting to track events when links are clicked on my site in a method similar to the following. ``` <a href="/example" class="track">Example</a> <script type="text/javascript"> jQuery(function($) { // track clicks on all anchor tags that require it $('a.track').live('click', function(e) { // send an AJAX request to our event tracking URL for the server to track it $.get('/events/track', { url: $(this).attr('href'), text: $(this).text() }); }); }); </script> ``` The problem that I'm having is that a new page load interrupts the AJAX request, and so sometimes these events aren't being tracked. I know Google Analytics has a `_trackPageview` function that can be attached to onclick events though, and this doesn't seem to be an issue for that. I'm wondering what's different about their call vs. mine that I'm seeing this race condition, and GA isn't. e.g.: ``` <a href="/example" onclick="javascript:pageTracker._trackPageview('/click/example');">Example</a> ``` Note that I'm not worried about the result of the AJAX request...I simply want it to ping the server with the fact that an event happened. *(Also, I expect I'll get at least one answer that says to simply track the new page load from the server side, not the client side. This is not an acceptable answer for this question. I'm looking for something like how Google Analytics' `trackPageview` function works on the click event of anchor tags regardless of a new page being loaded.)*
2010/07/09
[ "https://Stackoverflow.com/questions/3214023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/107277/" ]
Running Google's `trackPageview` method through a proxy like Charles shows that calls to `trackPageview( )` request a pixel from Google's servers with various parameters set, which is how most analytics packages wind up implementing such pieces of functionality (Omniture does the same). Basically, to get around ansynchronous requests not completing, they have the client request an image and crunch the parameters passed in those requests on the server side. For your end, you'd need to implement the same thing: write a utility method that requests an image from your server, passing along the information you're interested in via URL parameters (something like /track.gif?page=foo.html&link=Click%20Me&bar=baz); the server would then log those parameters in the database and send back the gif. After that, it's merely slicing and dicing the data you've collected to generate reports.
Matt, If you just want to make sure that the tracking pixel request is made and you don't depend upon response then just doing document.write for the tracking pixel image will do the work. And you can do the document.write in your onclick handler. AFA race condition between href and onclick handler of anchor element is concerned the order is well defined. the event handler script is executed first the default action takes place afterwards (in this case the default handler is href) (Source : [Href and onclick issue in anchor link](https://stackoverflow.com/questions/964534/href-and-onclick-issue-in-anchor-link)) But yes, if you depend upon the response of the tracking request to the server then you will have to make it synchronous. Suggested option would be to call some javascript function to wrap the already defined onclick handlers and then in the order make the calls. Make sure that your tracking request is not asynchronous. Though it is suggested that you should not be dependent upon the response of the tracking pixel request.
48,104,061
I am new to Python and is about to build a GUI using tkinter. The GUI consists of a Notebook and I am trying to create a event handler for when the user click with the mouse on the different tabs. However when I click on a tab, the handlerfunction 'works' but it seems the selected tab is not 'updated' before the function is called. As a sidenote: So far I have mainly used 'Tkinter 8.5 reference: a GUI for Python (Shipman)'. Please see code below. Grateful for any suggestions! ``` from tkinter import * import tkinter.ttk as ttk root = Tk() note = ttk.Notebook(root) tab1 = Frame(note,width = 10) tab2 = Frame(note,width = 10) tab3 = Frame(note,width = 10) note.add(tab1, text = "Tab One") note.add(tab2, text = "Tab Two") note.add(tab3, text = "Tab Three") note.grid() def personalData(event): if event.widget.index("current") == 0: print("One!") else: print("Not One!") note.bind('<1>',personalData) root.mainloop() ```
2018/01/04
[ "https://Stackoverflow.com/questions/48104061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2423970/" ]
The reason this is happening is due to the order that events are processed. Custom bindings on widgets are processed before the built-in bindings, meaning that your binding on `<1>` will fire before the tab actually changes. For more information, research "binding tags" (or sometimes called "bind tags" or "bindtags"). A better solution is to bind on the virtual event `<<NotebookTabChanged>>`, which the notebook will generate after the tab has changed. Example: ``` note.bind("<<NotebookTabChanged>>", personalData) ``` An additional benefit to binding to the virtual event rather than a mouse click is that the event will fire even if the tab is changed via some other mechanism besides a mouse click. For example, if a tab has the keyboard focus, you can select the next or previous tab using the arrow keys on your keyboard.
You're experiencing this because [events of bind are handled *before* events of bindtags](https://stackoverflow.com/a/3513906/7032856), in other words, you're actually *not* changing the tab before the callback function to `"<1>"` event, `personalData` is handled. --- One workaround would be to rotate the order of the sequence which the events are being handled with. Add after `note.bind(...)`: ``` note.bindtags((note.bindtags()[1:] + note.bindtags()[:1])) ``` this will put the bind's callback as the last in the sequence and shift the rest to up in the queue. --- Another way would be to replace the actual event(`"<1>"`) to a more appropriate one like in [Novel's suggestion](https://stackoverflow.com/questions/48104061/python-tkinter-bindtag-event-handling-how-to-upadte-which-tab-is-currently-sel/48104334#comment83183825_48104061).
48,104,061
I am new to Python and is about to build a GUI using tkinter. The GUI consists of a Notebook and I am trying to create a event handler for when the user click with the mouse on the different tabs. However when I click on a tab, the handlerfunction 'works' but it seems the selected tab is not 'updated' before the function is called. As a sidenote: So far I have mainly used 'Tkinter 8.5 reference: a GUI for Python (Shipman)'. Please see code below. Grateful for any suggestions! ``` from tkinter import * import tkinter.ttk as ttk root = Tk() note = ttk.Notebook(root) tab1 = Frame(note,width = 10) tab2 = Frame(note,width = 10) tab3 = Frame(note,width = 10) note.add(tab1, text = "Tab One") note.add(tab2, text = "Tab Two") note.add(tab3, text = "Tab Three") note.grid() def personalData(event): if event.widget.index("current") == 0: print("One!") else: print("Not One!") note.bind('<1>',personalData) root.mainloop() ```
2018/01/04
[ "https://Stackoverflow.com/questions/48104061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2423970/" ]
You're experiencing this because [events of bind are handled *before* events of bindtags](https://stackoverflow.com/a/3513906/7032856), in other words, you're actually *not* changing the tab before the callback function to `"<1>"` event, `personalData` is handled. --- One workaround would be to rotate the order of the sequence which the events are being handled with. Add after `note.bind(...)`: ``` note.bindtags((note.bindtags()[1:] + note.bindtags()[:1])) ``` this will put the bind's callback as the last in the sequence and shift the rest to up in the queue. --- Another way would be to replace the actual event(`"<1>"`) to a more appropriate one like in [Novel's suggestion](https://stackoverflow.com/questions/48104061/python-tkinter-bindtag-event-handling-how-to-upadte-which-tab-is-currently-sel/48104334#comment83183825_48104061).
Note that when you click another tab, the current tab is still the previous tab; if you change your binding to ``` note.bind('<ButtonRelease-1>',personalData) ``` it will work right, as now, when the mouse button is released, the current tab is the tab already selected.
48,104,061
I am new to Python and is about to build a GUI using tkinter. The GUI consists of a Notebook and I am trying to create a event handler for when the user click with the mouse on the different tabs. However when I click on a tab, the handlerfunction 'works' but it seems the selected tab is not 'updated' before the function is called. As a sidenote: So far I have mainly used 'Tkinter 8.5 reference: a GUI for Python (Shipman)'. Please see code below. Grateful for any suggestions! ``` from tkinter import * import tkinter.ttk as ttk root = Tk() note = ttk.Notebook(root) tab1 = Frame(note,width = 10) tab2 = Frame(note,width = 10) tab3 = Frame(note,width = 10) note.add(tab1, text = "Tab One") note.add(tab2, text = "Tab Two") note.add(tab3, text = "Tab Three") note.grid() def personalData(event): if event.widget.index("current") == 0: print("One!") else: print("Not One!") note.bind('<1>',personalData) root.mainloop() ```
2018/01/04
[ "https://Stackoverflow.com/questions/48104061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2423970/" ]
The reason this is happening is due to the order that events are processed. Custom bindings on widgets are processed before the built-in bindings, meaning that your binding on `<1>` will fire before the tab actually changes. For more information, research "binding tags" (or sometimes called "bind tags" or "bindtags"). A better solution is to bind on the virtual event `<<NotebookTabChanged>>`, which the notebook will generate after the tab has changed. Example: ``` note.bind("<<NotebookTabChanged>>", personalData) ``` An additional benefit to binding to the virtual event rather than a mouse click is that the event will fire even if the tab is changed via some other mechanism besides a mouse click. For example, if a tab has the keyboard focus, you can select the next or previous tab using the arrow keys on your keyboard.
Note that when you click another tab, the current tab is still the previous tab; if you change your binding to ``` note.bind('<ButtonRelease-1>',personalData) ``` it will work right, as now, when the mouse button is released, the current tab is the tab already selected.
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
There are several things wrong or not logical in your code: **1)** If you only use `num` to print the value `1`, why not change it to: ``` int num = 1; ``` or ``` System.out.println(" blah blah blah " + 1); ``` or even ``` System.out.println(" blah blah blah 1"); ``` **2)** You make a new object of the type/class Coffee, but you never set the variable `String coffeeType` in the objects. The standard way to do this is to make a constructor like so: in `main()`: ``` Coffee latte = new Coffee("latte"); ``` and in your `Coffee` class make the constructor: ``` public Coffee(String coffee){ this.coffeeType = coffee; } ``` **3)** You have to compare Strings with the [.equal()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)) method: ``` if("latte".equals(this.coffeeType)){ System.out.println("\nThis is latte coffee"); } ``` Some further notes as mentioned by [npinti](https://stackoverflow.com/questions/30885132/simple-java-program-error-using-multiple-classes/30885237?noredirect=1#comment49810635_30885132): use getter and setter methods to set variables en retrieve them: ``` public void setType(String type){ this.coffeeType = type; } public void setPrice(int price){ this.price = price; } public int getPrice(){ return this.price; } ```
change string comparison ``` coffeeType == "latte" ``` to ``` coffeeType.equals("latte") ``` that is how java compares string values. Make the changes in rest of your code with respect to these changes.
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
change string comparison ``` coffeeType == "latte" ``` to ``` coffeeType.equals("latte") ``` that is how java compares string values. Make the changes in rest of your code with respect to these changes.
Try this code. I have tried to use java conventions for your understanding. Your ClassyClass class: ``` import java.util.*; public class ClassyClass { ArrayList<Coffee> myClub; Scanner myInput; public ClassyClass() { myClub = new ArrayList<Coffee>(); myInput = new Scanner(System.in); myClub.add(new Coffee("latte", 5)); myClub.add(new Coffee("capuccinno", 11)); System.out.println("Do you want to place an order? Enter 1 for yes and 2 for no."); int choice = myInput.nextInt(); System.out.println(myClub.size()); if (choice == 1) { myCoffeeClub(); } else { } } public void myCoffeeClub() { System.out.print("Enter latte or capuccinno: "); String item = myInput.next(); int itemPrice = 0; for (Coffee s : myClub) { if (s.cName.equals(item)) { itemPrice = s.cPrice; } } System.out.println ("The price of "+item+" is "+itemPrice+"."); } } ``` Your Coffee class: ``` public class Coffee { String cName; int cPrice; public Coffee (String cName, int cPrice) { this.cName = cName; this.cPrice = cPrice; } } ```
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
change string comparison ``` coffeeType == "latte" ``` to ``` coffeeType.equals("latte") ``` that is how java compares string values. Make the changes in rest of your code with respect to these changes.
You should have set coffeeType while setting price and you would have got correct results. ``` public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); latte.coffeeType = "latte"; latte.price = 5; Coffee capuccino = new Coffee(); capuccino.coffeeType = "capuccino"; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } public class Coffee { int price; String coffeeType; void beverage() { if (this.coffeeType.equals("latte")) { System.out.println("The price of latte is " + this.price); } else if (this.coffeeType.equals("capuccino")) { System.out.println("The price of a cappuccino is " + this.price); } } } ```
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
change string comparison ``` coffeeType == "latte" ``` to ``` coffeeType.equals("latte") ``` that is how java compares string values. Make the changes in rest of your code with respect to these changes.
In java the `==` operator compares an object reference. To compare a string you should use the `string.equals("..")` method.
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
There are several things wrong or not logical in your code: **1)** If you only use `num` to print the value `1`, why not change it to: ``` int num = 1; ``` or ``` System.out.println(" blah blah blah " + 1); ``` or even ``` System.out.println(" blah blah blah 1"); ``` **2)** You make a new object of the type/class Coffee, but you never set the variable `String coffeeType` in the objects. The standard way to do this is to make a constructor like so: in `main()`: ``` Coffee latte = new Coffee("latte"); ``` and in your `Coffee` class make the constructor: ``` public Coffee(String coffee){ this.coffeeType = coffee; } ``` **3)** You have to compare Strings with the [.equal()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)) method: ``` if("latte".equals(this.coffeeType)){ System.out.println("\nThis is latte coffee"); } ``` Some further notes as mentioned by [npinti](https://stackoverflow.com/questions/30885132/simple-java-program-error-using-multiple-classes/30885237?noredirect=1#comment49810635_30885132): use getter and setter methods to set variables en retrieve them: ``` public void setType(String type){ this.coffeeType = type; } public void setPrice(int price){ this.price = price; } public int getPrice(){ return this.price; } ```
Try this code. I have tried to use java conventions for your understanding. Your ClassyClass class: ``` import java.util.*; public class ClassyClass { ArrayList<Coffee> myClub; Scanner myInput; public ClassyClass() { myClub = new ArrayList<Coffee>(); myInput = new Scanner(System.in); myClub.add(new Coffee("latte", 5)); myClub.add(new Coffee("capuccinno", 11)); System.out.println("Do you want to place an order? Enter 1 for yes and 2 for no."); int choice = myInput.nextInt(); System.out.println(myClub.size()); if (choice == 1) { myCoffeeClub(); } else { } } public void myCoffeeClub() { System.out.print("Enter latte or capuccinno: "); String item = myInput.next(); int itemPrice = 0; for (Coffee s : myClub) { if (s.cName.equals(item)) { itemPrice = s.cPrice; } } System.out.println ("The price of "+item+" is "+itemPrice+"."); } } ``` Your Coffee class: ``` public class Coffee { String cName; int cPrice; public Coffee (String cName, int cPrice) { this.cName = cName; this.cPrice = cPrice; } } ```
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
There are several things wrong or not logical in your code: **1)** If you only use `num` to print the value `1`, why not change it to: ``` int num = 1; ``` or ``` System.out.println(" blah blah blah " + 1); ``` or even ``` System.out.println(" blah blah blah 1"); ``` **2)** You make a new object of the type/class Coffee, but you never set the variable `String coffeeType` in the objects. The standard way to do this is to make a constructor like so: in `main()`: ``` Coffee latte = new Coffee("latte"); ``` and in your `Coffee` class make the constructor: ``` public Coffee(String coffee){ this.coffeeType = coffee; } ``` **3)** You have to compare Strings with the [.equal()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)) method: ``` if("latte".equals(this.coffeeType)){ System.out.println("\nThis is latte coffee"); } ``` Some further notes as mentioned by [npinti](https://stackoverflow.com/questions/30885132/simple-java-program-error-using-multiple-classes/30885237?noredirect=1#comment49810635_30885132): use getter and setter methods to set variables en retrieve them: ``` public void setType(String type){ this.coffeeType = type; } public void setPrice(int price){ this.price = price; } public int getPrice(){ return this.price; } ```
You should have set coffeeType while setting price and you would have got correct results. ``` public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); latte.coffeeType = "latte"; latte.price = 5; Coffee capuccino = new Coffee(); capuccino.coffeeType = "capuccino"; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } public class Coffee { int price; String coffeeType; void beverage() { if (this.coffeeType.equals("latte")) { System.out.println("The price of latte is " + this.price); } else if (this.coffeeType.equals("capuccino")) { System.out.println("The price of a cappuccino is " + this.price); } } } ```
30,885,132
classyclass.java : ``` package work1; public class classyclass { public static void main(String[] args) { int num; num = 0; num++; System.out.println(" blah blah blah " + num); Coffee latte = new Coffee(); Coffee capuccino = new Coffee(); latte.price = 5; capuccino.price = 11; latte.beverage(); capuccino.beverage(); } } ``` Coffee.java : ``` package work1; public class Coffee { int price; String coffeeType; void beverage() { if (coffeeType == "latte" ) { System.out.println("The price of latte is " + latte.price ); } else if(coffeeType == "capuccino") { System.out.println("The price of a cappuccino is " + capuccino.price); } } } ``` As an amateur C programmer venturing into Java ,I am getting really confused with using these classes and objects. What I want is to take the value from the classyclass class into the coffee class and then execute on that data back again in the main method. I am mixing stuff up , please help
2015/06/17
[ "https://Stackoverflow.com/questions/30885132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5018454/" ]
There are several things wrong or not logical in your code: **1)** If you only use `num` to print the value `1`, why not change it to: ``` int num = 1; ``` or ``` System.out.println(" blah blah blah " + 1); ``` or even ``` System.out.println(" blah blah blah 1"); ``` **2)** You make a new object of the type/class Coffee, but you never set the variable `String coffeeType` in the objects. The standard way to do this is to make a constructor like so: in `main()`: ``` Coffee latte = new Coffee("latte"); ``` and in your `Coffee` class make the constructor: ``` public Coffee(String coffee){ this.coffeeType = coffee; } ``` **3)** You have to compare Strings with the [.equal()](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#equals(java.lang.Object)) method: ``` if("latte".equals(this.coffeeType)){ System.out.println("\nThis is latte coffee"); } ``` Some further notes as mentioned by [npinti](https://stackoverflow.com/questions/30885132/simple-java-program-error-using-multiple-classes/30885237?noredirect=1#comment49810635_30885132): use getter and setter methods to set variables en retrieve them: ``` public void setType(String type){ this.coffeeType = type; } public void setPrice(int price){ this.price = price; } public int getPrice(){ return this.price; } ```
In java the `==` operator compares an object reference. To compare a string you should use the `string.equals("..")` method.
9,672
if you take a look at my website: [NerdyFuture](http://nerdyfuture.byethost24.com). You can probably see the couple of pictures at the top of the website. I made this in a custom HTML module, now what I want to achieve is to input data from another module in the custom HTML module I made. I want input the data from the module: Mini Frontpage. So the data that I need from Mini Frontpage is the title,thumbnail,description and link from one article. How can I achieve this?
2015/04/27
[ "https://joomla.stackexchange.com/questions/9672", "https://joomla.stackexchange.com", "https://joomla.stackexchange.com/users/3396/" ]
To do this, you can simply load module 1 into module 2. In your Custom HTML module, add the following into the textarea: ``` {loadposition XXX} ``` Where `XXX` is the position of your first module. To load an article into your Custom HTML module, you can also use NoNumber's [Articles Anywhere](https://www.nonumber.nl/extensions/articlesanywhere) plugin.
Another way to load a module from your custom HTML extension would be to include the following code: ``` echo JHtml::_('content.prepare', '{loadposition someposition}'); ``` Here you can read in more detail: <https://www.joomlashack.com/blog/joomla-how-to/module-position-component/>
66,799,165
I cannot see the collections and values in the Cloud Firestore after they were created in my Flutter app. I am working on a Flutter mobile app by using Flutter and Firebase. I use cloud firestore to keep data. when I run the app, I can see "hi" from VS Code's terminal, but when I went to the firebase, refresh the cloud firestore page, I can not see the collection and values in the cloud firestore. I tried to delete firebase project and recreate it. But it did not work. I tried to use `Collection("users").add(...).then(value){print(value.id);}`. From the terminal, I can see the ID. But I still cannot see the collection and values in the Cloud Firestore. I do not know what is wrong with my app. I need help. The code is: ``` import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp()); } class MyApp extends StatefulWidget { // This widget is the root of your application. override _createState() => _MyAppState(); class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { // firestore: a Firestore instance void _onPressed() async{ await FirebaseFirestore.instance.collection("users").doc().set({ "name": "john", "age": 50, "email": "example@example.com", "address": {"street": "street 24", "city": "new york"} }).then((value) { print('hi'); }); } return MaterialApp( home: Scaffold( body: Container( child: TextButton( onPressed: _onPressed, child: Text('Click'), ), ), ), ); } } ``` my build.gradle under app: ``` def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' } lintOptions { disable 'InvalidPackage' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.skype_clone" minSdkVersion 19 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } } flutter { source '../..' } dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-firestore:21.4.2' } apply plugin: 'com.google.gms.google-services' ``` the build.gradle under android: ``` buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.5' } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } ``` the security rule is: ``` rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write; } } } ``` I am appreciated for any help.
2021/03/25
[ "https://Stackoverflow.com/questions/66799165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15477306/" ]
I think that the problem is in this declaration ``` await Firebase.initializeApp(); ``` I think that you should remove the **await** keyword there and in the functcion, and when you use that function to initialize Firebase in the project you need to put the credential of the project as a parameter of that function, this is an example of how you should do it: ```js // Initialize default app // Retrieve your own options values by adding a web app on // https://console.firebase.google.com firebase.initializeApp({ apiKey: "AIza....", // Auth / General Use appId: "1:27992087142:web:ce....", // General Use projectId: "my-firebase-project", // General Use authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database storageBucket: "YOUR_APP.appspot.com", // Storage messagingSenderId: "123456789", // Cloud Messaging measurementId: "G-12345" // Analytics }); ``` Please let me know if this solve the problem
delete `await` keyword. It conflicts with `then`. You need to use or `await` or `then`: ``` void _onPressed() async{ FirebaseFirestore.instance.collection("users").doc().set({ "name": "john", "age": 50, "email": "example@example.com", "address": {"street": "street 24", "city": "new york"} }).then((value) { print('hi'); }); } ```
60,127,746
If I want to override a css class where specificity is not working, I use the following format which works well. ``` div[class="class-name"] { padding-bottom: 0; } ``` But how to override the class in the form `bx--modal-content > *:last-child` ? The following is not working. ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ```
2020/02/08
[ "https://Stackoverflow.com/questions/60127746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9433522/" ]
Your selector is invalid ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ``` You don't have a class attribute that is "bx--modal-content > \*:last-child" What you actually want is ``` div[class="bx--modal-content"] > *:last-child] { padding-bottom: 0; } ``` This will select that last child element contained within a `div` with a class attribute *exactly* equal to `bx--modal-content`. It will **not** match something like `<div class="bx--modal-content small">`
You could use, as an exception, an `!important` suffix in your first css, so that specificity rules are ignored. Place it juste before the trailing `;`
60,127,746
If I want to override a css class where specificity is not working, I use the following format which works well. ``` div[class="class-name"] { padding-bottom: 0; } ``` But how to override the class in the form `bx--modal-content > *:last-child` ? The following is not working. ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ```
2020/02/08
[ "https://Stackoverflow.com/questions/60127746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9433522/" ]
The selector should be ``` div[class="bx--modal-content"] > *:last-child { padding-bottom: 0; ] ``` The `> *:last-child` isn't part of the class, so it shouldn't be inside the `[ ... ]` brackets.
You could use, as an exception, an `!important` suffix in your first css, so that specificity rules are ignored. Place it juste before the trailing `;`
60,127,746
If I want to override a css class where specificity is not working, I use the following format which works well. ``` div[class="class-name"] { padding-bottom: 0; } ``` But how to override the class in the form `bx--modal-content > *:last-child` ? The following is not working. ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ```
2020/02/08
[ "https://Stackoverflow.com/questions/60127746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9433522/" ]
Your selector is invalid ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ``` You don't have a class attribute that is "bx--modal-content > \*:last-child" What you actually want is ``` div[class="bx--modal-content"] > *:last-child] { padding-bottom: 0; } ``` This will select that last child element contained within a `div` with a class attribute *exactly* equal to `bx--modal-content`. It will **not** match something like `<div class="bx--modal-content small">`
Try like this ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0 !important; } ``` or ``` :host /deep/ --> before the class if you want override plugins ```
60,127,746
If I want to override a css class where specificity is not working, I use the following format which works well. ``` div[class="class-name"] { padding-bottom: 0; } ``` But how to override the class in the form `bx--modal-content > *:last-child` ? The following is not working. ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0; } ```
2020/02/08
[ "https://Stackoverflow.com/questions/60127746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9433522/" ]
The selector should be ``` div[class="bx--modal-content"] > *:last-child { padding-bottom: 0; ] ``` The `> *:last-child` isn't part of the class, so it shouldn't be inside the `[ ... ]` brackets.
Try like this ``` div[class="bx--modal-content > *:last-child"] { padding-bottom: 0 !important; } ``` or ``` :host /deep/ --> before the class if you want override plugins ```
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[Hatha Yoga Pradipika](http://www.sacred-texts.com/hin/hyp/hyp03.htm) (1.61 to 1.70) gives the list of foods that are fit for the Yogi as well as those foods which a Yogi must avoid. Recommended foods are rice, wheat, milk etc. > > Varjayeddurjanaprāntam vahnistrīpathisevanam > Prātahsnānopavāsādi > kāyakleśavidhim tathā || > > > Wheat, rice, barley, shâstik (a kind of rice), good corns, milk, ghee, > sugar, butter, sugarcandy, honey, dried ginger, Parwal (a vegetable) > the five vegetables, moong, pure water; these are very beneficial to > those who practise Yoga. > > > > > Ghodhūmaśāliyavashāshtikaśobhanānnam > Kshīrājyakhandanavanītasi > hāmadhūni > Śunthīpatolakaphalādikapañchaśākam > > Mudghādidivyamudakam cha yamīndrapathyam || > > > A Yogî should eat tonics (things giving strength), well sweetened, > greasy (made with ghee), milk, butter, etc., which may increase humors > of the body, according to his desire > > > Now, the list of food which a Yogi must avoid while practising Yoga. This list includes foods like meat, liqour, sour, bitter foods etc. > > Katvāmlatīkshnalavanoshnaharītaśāka > > Sauvīratailatilasarshapamadyamatsyān > > Ājādimāmsadadhitakrakulatthakola > > Pinyākahingghulaśunādyamapathyamāhuh|| > > > Bitter, sour, saltish, hot, green vegetables, fermented, oily, mixed > with til seed, rape seed, intoxicating liquors, fish, meat, curds, > chhaasa pulses, plums, oilcake, asafœtida (hînga), garlic, onion, > etc., should not be eaten. > > > A Yogi must also always eat food which is first offered to Lord Shiva. > > Susnighdhamadhurāhāraśchaturthāmśavivarjitah > Bhujyate > śivasamprītyai mitāhārah sa uchyate|| > > > Abstemious feeding is that in which ¾ of hunger is satisfied with > food, well cooked with ghee and sweets, and eaten with the offering of > it to Śiva. > > > So, these are some rules about eating to be followed by a Yogi from Hatha Yoga Pradipika.
The Upanishadic advice is to eat food that keeps your body healthy. Treat food as a type of medicine. > > After saying thrice, ‘I have renounced, I have renounced, I have > renounced’, he shall take up the bamboo staff and don the loin-cloth, > uttering the mantra: ‘Let all beings be devoid of fear. Everything > originates from me. You are my friend and [you] protect me. You are > the strength, my friend. You are the vajra of Indra that killed Vrtra. > Be pleasant to me and remove all my sins.’ **He shall pertake of food as > if it were medicine. He shall eat as if taking medicine. He shall eat > as and when food is obtained.** ‘Oh [disciples], protect brahmacarya, > non-injury, non-possession and truth with care.’ 1 > > > 1 The outer and inner aspects of these qualities are: brahmacarya > (outer) = celibacy, (inner)=the dwelling of the mind on Brahman; > ahimsa=not injuring others, non-injury of oneself; > aparigraha=non-possession of anything other than what is needed for > bare subsistence, non-concern with all but Brahman; > satya=truthfulness, realization of the true nature of the Self. > > > *Arunyupanishad translated by Prof A A Ramanathan* Chandogya Upanishad says that some spiritual aspirant takes a vow to not eat fish and meat for a year or to permanently stop eating non-veg food. The exact shloka is: > > He who thus knows this Yajnayajniya Saman, woven in the limbs of the > body, is endowed with all the limbs, and is not crippled in any limb; > he reaches the full length of life, lives gloriously, becomes great > with offspring and cattle and great also with fame. His holy vow is > that he should not eat fish and meat for a year, or rather, he should > not eat fish and meat at all. > > > *Chandogya Upanishad 2.19.2* Swami Vivekananda has also discussed the question of food for Bhaktas. > > The question of food has always been one of the most vital with the > Bhaktas. Apart from the extravagance into which some of the Bhakti > sects have run, there is a great truth underlying this question of > food. We must remember that, according to the Sankhya philosophy, the > Sattva, Rajas, and Tamas, which in the state of homogeneous > equilibrium form the Prakriti, and in the heterogeneous disturbed > condition form the universe — are both the substance and the quality > of Prakriti. As such they are the materials out of which every human > form has been manufactured, and the predominance of the Sattva > material is what is absolutely necessary for spiritual development. > The materials which we receive through our food into our > body-structure go a great way to determine our mental constitution; > therefore the food we eat has to be particularly taken care of. > However, in this matter, as in others, the fanaticism into which the > disciples invariably fall is not to be laid at the door of the > masters. > > > And this discrimination of food is, after all, of secondary > importance. The very same passage quoted above is explained by > Shankara in his Bhâshya on the Upanishads in a different way by giving > an entirely different meaning to the word Âhâra, translated generally > as food. According to him, "That which is gathered in is Ahara. The > knowledge of the sensations, such as sound etc., is gathered in for > the enjoyment of the enjoyer (self); the purification of the knowledge > which gathers in the perception of the senses is the purifying of the > food (Ahara). The word 'purification-of-food' means the acquiring of > the knowledge of sensations untouched by the defects of attachment, > aversion, and delusion; such is the meaning. Therefore such knowledge > or Ahara being purified, the Sattva material of the possessor it — the > internal organ — will become purified, and the Sattva being purified, > an unbroken memory of the Infinite One, who has been known in His real > nature from scriptures, will result." > > > These two explanations are > apparently conflicting, yet both are true and necessary. The > manipulating and controlling of what may be called the finer body, viz > the mood, are no doubt higher functions than the controlling of the > grosser body of flesh. But the control of the grosser is absolutely > necessary to enable one to arrive at the control of the finer. The > beginner, therefore, must pay particular attention to all such > dietetic rules as have come down from the line of his accredited > teachers; but the extravagant, meaningless fanaticism, which has > driven religion entirely to the kitchen, as may be noticed in the case > of many of our sects, without any hope of the noble truth of that > religion ever coming out to the sunlight of spirituality, is a > peculiar sort of pure and simple materialism. It is neither Jnâna, nor > Bhakti, nor Karma; it is a special kind of lunacy, and those who pin > their souls to it are more likely to go to lunatic asylums than to > Brahmaloka. So it stands to reason that discrimination in the choice > of food is necessary for the attainment of this higher state of mental > composition which cannot be easily obtained otherwise. > > > *The Complete Works of Swami Vivekananda, Volume 3, Bhakti Yoga, The Method and the Means* **A note of caution** Food suggested in any Hatha Yoga book is not accepted by all Yogis. This is because some Yogis think that Hatha yoga is bad for spirituality. It is bad according to Sri Ramakrishna. > > A DEVOTEE: "Sir, what is hathayoga like?" > > > MASTER: "A man practising hathayoga dwells a great deal on his body. > He washes his intestines by means of a bamboo tube through his anus. > He draws ghee and milk through his sexual organ. He learns how to > manipulate his tongue by performing exercises. He sits in a fixed > posture and now and then levitates. All these are actions of prana. A > magician was performing his feats when his tongue turned up and clove > to the roof of his mouth. Immediately his body became motionless. > People thought he was dead. He was buried and remained many years in > the grave. After a long time the grave somehow broke open. Suddenly > the man regained consciousness of the world and cried out, 'Come > delusion! Come confusion!1 (All laugh.) All these are actions of > prana. > > > "**The Vedantists do not accept hathayoga.** There is also rajayoga. > Rajayoga describes how to achieve union with God through the mind — by > means of discrimination and bhakti. **This yoga is good. Hathayoga is > not good.** The life of a man in the Kaliyuga is dependent on food." > > > *The Gospel of Sri Ramakrishna, With the devotees at Dakshineswar (II), December 9, 1883* > > MANILAL: "And what about hathayoga?" > > > MASTER: "The hathayogis identify themselves with their bodies. They > practise internal washing and similar disciplines, and devote > themselves only to the care of the body. Their ideal is to increase > longevity. They serve the body day and night. **That is not good**. > > > *The Gospel of Sri Ramakrishna, The master in various moods, October 2, 1884*
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[Hatha Yoga Pradipika](http://www.sacred-texts.com/hin/hyp/hyp03.htm) (1.61 to 1.70) gives the list of foods that are fit for the Yogi as well as those foods which a Yogi must avoid. Recommended foods are rice, wheat, milk etc. > > Varjayeddurjanaprāntam vahnistrīpathisevanam > Prātahsnānopavāsādi > kāyakleśavidhim tathā || > > > Wheat, rice, barley, shâstik (a kind of rice), good corns, milk, ghee, > sugar, butter, sugarcandy, honey, dried ginger, Parwal (a vegetable) > the five vegetables, moong, pure water; these are very beneficial to > those who practise Yoga. > > > > > Ghodhūmaśāliyavashāshtikaśobhanānnam > Kshīrājyakhandanavanītasi > hāmadhūni > Śunthīpatolakaphalādikapañchaśākam > > Mudghādidivyamudakam cha yamīndrapathyam || > > > A Yogî should eat tonics (things giving strength), well sweetened, > greasy (made with ghee), milk, butter, etc., which may increase humors > of the body, according to his desire > > > Now, the list of food which a Yogi must avoid while practising Yoga. This list includes foods like meat, liqour, sour, bitter foods etc. > > Katvāmlatīkshnalavanoshnaharītaśāka > > Sauvīratailatilasarshapamadyamatsyān > > Ājādimāmsadadhitakrakulatthakola > > Pinyākahingghulaśunādyamapathyamāhuh|| > > > Bitter, sour, saltish, hot, green vegetables, fermented, oily, mixed > with til seed, rape seed, intoxicating liquors, fish, meat, curds, > chhaasa pulses, plums, oilcake, asafœtida (hînga), garlic, onion, > etc., should not be eaten. > > > A Yogi must also always eat food which is first offered to Lord Shiva. > > Susnighdhamadhurāhāraśchaturthāmśavivarjitah > Bhujyate > śivasamprītyai mitāhārah sa uchyate|| > > > Abstemious feeding is that in which ¾ of hunger is satisfied with > food, well cooked with ghee and sweets, and eaten with the offering of > it to Śiva. > > > So, these are some rules about eating to be followed by a Yogi from Hatha Yoga Pradipika.
[**Yogatattva Upanishad**](https://www.wisdomlib.org/hinduism/book/yogatattva-upanishad-of-krishna-yajurveda/d/doc217055.html) (3rd paragraph ) gives a small glimpse of it with generally healthy vegetarian food is enough for a Yogi > > The proficient in Yoga should abandon the food detrimental to the practice of Yoga. > He should give up salt, mustard; things sour, hot, pungent, or bitter vegetables; asafoetida, > etc., worship of fire, women, walking, bathing at sunrise, emaciation of the body by fasts, etc. > During the early stages of practice, food of milk and ghee is ordained; also food consisting of > wheat, green pulse and red rice are said to favour the progress > > >
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[Hatha Yoga Pradipika](http://www.sacred-texts.com/hin/hyp/hyp03.htm) (1.61 to 1.70) gives the list of foods that are fit for the Yogi as well as those foods which a Yogi must avoid. Recommended foods are rice, wheat, milk etc. > > Varjayeddurjanaprāntam vahnistrīpathisevanam > Prātahsnānopavāsādi > kāyakleśavidhim tathā || > > > Wheat, rice, barley, shâstik (a kind of rice), good corns, milk, ghee, > sugar, butter, sugarcandy, honey, dried ginger, Parwal (a vegetable) > the five vegetables, moong, pure water; these are very beneficial to > those who practise Yoga. > > > > > Ghodhūmaśāliyavashāshtikaśobhanānnam > Kshīrājyakhandanavanītasi > hāmadhūni > Śunthīpatolakaphalādikapañchaśākam > > Mudghādidivyamudakam cha yamīndrapathyam || > > > A Yogî should eat tonics (things giving strength), well sweetened, > greasy (made with ghee), milk, butter, etc., which may increase humors > of the body, according to his desire > > > Now, the list of food which a Yogi must avoid while practising Yoga. This list includes foods like meat, liqour, sour, bitter foods etc. > > Katvāmlatīkshnalavanoshnaharītaśāka > > Sauvīratailatilasarshapamadyamatsyān > > Ājādimāmsadadhitakrakulatthakola > > Pinyākahingghulaśunādyamapathyamāhuh|| > > > Bitter, sour, saltish, hot, green vegetables, fermented, oily, mixed > with til seed, rape seed, intoxicating liquors, fish, meat, curds, > chhaasa pulses, plums, oilcake, asafœtida (hînga), garlic, onion, > etc., should not be eaten. > > > A Yogi must also always eat food which is first offered to Lord Shiva. > > Susnighdhamadhurāhāraśchaturthāmśavivarjitah > Bhujyate > śivasamprītyai mitāhārah sa uchyate|| > > > Abstemious feeding is that in which ¾ of hunger is satisfied with > food, well cooked with ghee and sweets, and eaten with the offering of > it to Śiva. > > > So, these are some rules about eating to be followed by a Yogi from Hatha Yoga Pradipika.
As per Ramana Maharshi <http://bhagwan-ramana-maharshi.blogspot.com/2008/12/ramana-maharshi-on-vegetarianism-eating.html> <http://spiritualblossoms.blogspot.com/2010/08/sri-ramana-maharshi-diet.html> > > Question : What about diet? > > Ramana Maharshi : Food affects the mind. > For the practice of any kind of yoga, vegetarianism is absolutely > necessary since it makes the mind more sattvic [pure and harmonious]. > > > Question : Could one receive spiritual illumination while eating flesh > foods? > > Ramana Maharshi : Yes, but abandon them gradually and accustom > yourself to sattvic foods. However, once you have attained > illumination it will make less difference what you eat, as, on a great > fire, it is immaterial what fuel is added. > > > Question : We Europeans are accustomed to a particular diet and a > change of diet affects the health and weakens the mind. Is it not > necessary to keep up one's physical health? > > Ramana Maharshi : Quite > necessary. The weaker the body the stronger the mind grows. > > > Question : In the absence of our usual diet our health suffers and the > mind loses strength. > > Ramana Maharshi : What do you mean by strength of > mind? > > > Question : The power to eliminate worldly attachment. > > Ramana Maharshi > : The quality of food influences the mind. The mind feeds on the food > consumed. > > > Question : Really! Then how can Europeans adjust themselves to sattvic > food only? > > Ramana Maharshi : Habit is only adjustment to the > environment. It is the mind that matters. The fact is that the mind > has been trained to think certain foods tasty and good. The food > material is to be had both in vegetarian and non-vegetarian diet > equally well. But the mind desires such food as it is accustomed to > and considers tasty. > > > Question : Are there restrictions for the realized man with regard to > food? > > Ramana Maharshi : No. He is steady and not influenced by the > food he takes. > > > Question: Is it not killing life to prepare meat diet? > > Ramana Maharshi > : Ahimsa [non-violence] stands foremost in the code of discipline for > the yogis. > > > Question : Even plants have life. > > Ramana Maharshi : So too the slabs > you sit on! > > > Question : May we gradually get ourselves accustomed to vegetarian > food? > > Ramana Maharshi : Yes. That is the way. > > > Question : Is it harmless to continue smoking? > > Ramana Maharshi : No, > for tobacco is a poison. It is better to do without it. It is good > that you have given up smoking. Men are enslaved by tobacco and cannot > give it up. But tobacco only gives a temporary stimulation to which > there must be a reaction with craving for more. It is also not good > for meditation practice. > > > Question : Do you recommend that meat and alcoholic drinks be given > up? > > Ramana Maharshi : It is advisable to give them up because this > abstention is a useful aid for beginners. The difficulty in > surrendering them does not arise because they are really necessary, > but merely because we have become inured by custom and habit to them. > > > Question : Generally speaking, what are the rules of conduct which an > aspirant should follow? > > Ramana Maharshi : Moderation in food, > moderation in sleep and moderation in speech. > > >
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[Hatha Yoga Pradipika](http://www.sacred-texts.com/hin/hyp/hyp03.htm) (1.61 to 1.70) gives the list of foods that are fit for the Yogi as well as those foods which a Yogi must avoid. Recommended foods are rice, wheat, milk etc. > > Varjayeddurjanaprāntam vahnistrīpathisevanam > Prātahsnānopavāsādi > kāyakleśavidhim tathā || > > > Wheat, rice, barley, shâstik (a kind of rice), good corns, milk, ghee, > sugar, butter, sugarcandy, honey, dried ginger, Parwal (a vegetable) > the five vegetables, moong, pure water; these are very beneficial to > those who practise Yoga. > > > > > Ghodhūmaśāliyavashāshtikaśobhanānnam > Kshīrājyakhandanavanītasi > hāmadhūni > Śunthīpatolakaphalādikapañchaśākam > > Mudghādidivyamudakam cha yamīndrapathyam || > > > A Yogî should eat tonics (things giving strength), well sweetened, > greasy (made with ghee), milk, butter, etc., which may increase humors > of the body, according to his desire > > > Now, the list of food which a Yogi must avoid while practising Yoga. This list includes foods like meat, liqour, sour, bitter foods etc. > > Katvāmlatīkshnalavanoshnaharītaśāka > > Sauvīratailatilasarshapamadyamatsyān > > Ājādimāmsadadhitakrakulatthakola > > Pinyākahingghulaśunādyamapathyamāhuh|| > > > Bitter, sour, saltish, hot, green vegetables, fermented, oily, mixed > with til seed, rape seed, intoxicating liquors, fish, meat, curds, > chhaasa pulses, plums, oilcake, asafœtida (hînga), garlic, onion, > etc., should not be eaten. > > > A Yogi must also always eat food which is first offered to Lord Shiva. > > Susnighdhamadhurāhāraśchaturthāmśavivarjitah > Bhujyate > śivasamprītyai mitāhārah sa uchyate|| > > > Abstemious feeding is that in which ¾ of hunger is satisfied with > food, well cooked with ghee and sweets, and eaten with the offering of > it to Śiva. > > > So, these are some rules about eating to be followed by a Yogi from Hatha Yoga Pradipika.
Sanatana Dharma aka Hinduism has 4 sects of people depending on their duty Brahmin (one whose life is of knowledge) ex:- Teacher, priest, doctor, scholar, architect, judge.. Kshatriya (one whose life is of a warrior) ex:- soldier, king, cop, fireman etc., Vaishya (one whose life is of trade) ex:- shop owner, trader, businessman Shudra (one whose life is of labor) ex:- construction worker, engineer, driver etc., Brahmin and Vaishya's profession requires their mental health, alertness and well being to higher than any of their other well being (physical, social etc.,). So the foods suggested are satvik --> vegetarian, dairy, honey and so on. There are a lot of aphrodisiac vegetarian food and they are to be avoided too. It is common knowledge that those who are sexually more active always involve in those thought are less capable of being rational in dealings with those to whom they are sexually attracted. If you are a straight heterosexual business man or a priest with your diet involving a lot of aphrodisiacs then your chances of getting compromised with those of opposite sex are more. vegetarian food which doesn't affect your mood, rationality, alertness etc are recommended. Coffee is vegetarian, mushrooms are vegetarian and so are many drugs. So anything that doesn't affect the natural state and well being of your body and mind is fine. Shudra and Kshatriya's duties require that they prioritize their physical wellbeing. That is why tamasic food (meat, aphrodasiacs, alcohol etc.,) are not forbidden or ill advised for them. If you are following the satvic (hatha, pranayama etc.,) way of yoga then eat satvic food. If you are following the tamasic way of yoga (kundalini, tantric) then you can even go for the tamasic food too but strictly under a guru's guidance.
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[**Yogatattva Upanishad**](https://www.wisdomlib.org/hinduism/book/yogatattva-upanishad-of-krishna-yajurveda/d/doc217055.html) (3rd paragraph ) gives a small glimpse of it with generally healthy vegetarian food is enough for a Yogi > > The proficient in Yoga should abandon the food detrimental to the practice of Yoga. > He should give up salt, mustard; things sour, hot, pungent, or bitter vegetables; asafoetida, > etc., worship of fire, women, walking, bathing at sunrise, emaciation of the body by fasts, etc. > During the early stages of practice, food of milk and ghee is ordained; also food consisting of > wheat, green pulse and red rice are said to favour the progress > > >
The Upanishadic advice is to eat food that keeps your body healthy. Treat food as a type of medicine. > > After saying thrice, ‘I have renounced, I have renounced, I have > renounced’, he shall take up the bamboo staff and don the loin-cloth, > uttering the mantra: ‘Let all beings be devoid of fear. Everything > originates from me. You are my friend and [you] protect me. You are > the strength, my friend. You are the vajra of Indra that killed Vrtra. > Be pleasant to me and remove all my sins.’ **He shall pertake of food as > if it were medicine. He shall eat as if taking medicine. He shall eat > as and when food is obtained.** ‘Oh [disciples], protect brahmacarya, > non-injury, non-possession and truth with care.’ 1 > > > 1 The outer and inner aspects of these qualities are: brahmacarya > (outer) = celibacy, (inner)=the dwelling of the mind on Brahman; > ahimsa=not injuring others, non-injury of oneself; > aparigraha=non-possession of anything other than what is needed for > bare subsistence, non-concern with all but Brahman; > satya=truthfulness, realization of the true nature of the Self. > > > *Arunyupanishad translated by Prof A A Ramanathan* Chandogya Upanishad says that some spiritual aspirant takes a vow to not eat fish and meat for a year or to permanently stop eating non-veg food. The exact shloka is: > > He who thus knows this Yajnayajniya Saman, woven in the limbs of the > body, is endowed with all the limbs, and is not crippled in any limb; > he reaches the full length of life, lives gloriously, becomes great > with offspring and cattle and great also with fame. His holy vow is > that he should not eat fish and meat for a year, or rather, he should > not eat fish and meat at all. > > > *Chandogya Upanishad 2.19.2* Swami Vivekananda has also discussed the question of food for Bhaktas. > > The question of food has always been one of the most vital with the > Bhaktas. Apart from the extravagance into which some of the Bhakti > sects have run, there is a great truth underlying this question of > food. We must remember that, according to the Sankhya philosophy, the > Sattva, Rajas, and Tamas, which in the state of homogeneous > equilibrium form the Prakriti, and in the heterogeneous disturbed > condition form the universe — are both the substance and the quality > of Prakriti. As such they are the materials out of which every human > form has been manufactured, and the predominance of the Sattva > material is what is absolutely necessary for spiritual development. > The materials which we receive through our food into our > body-structure go a great way to determine our mental constitution; > therefore the food we eat has to be particularly taken care of. > However, in this matter, as in others, the fanaticism into which the > disciples invariably fall is not to be laid at the door of the > masters. > > > And this discrimination of food is, after all, of secondary > importance. The very same passage quoted above is explained by > Shankara in his Bhâshya on the Upanishads in a different way by giving > an entirely different meaning to the word Âhâra, translated generally > as food. According to him, "That which is gathered in is Ahara. The > knowledge of the sensations, such as sound etc., is gathered in for > the enjoyment of the enjoyer (self); the purification of the knowledge > which gathers in the perception of the senses is the purifying of the > food (Ahara). The word 'purification-of-food' means the acquiring of > the knowledge of sensations untouched by the defects of attachment, > aversion, and delusion; such is the meaning. Therefore such knowledge > or Ahara being purified, the Sattva material of the possessor it — the > internal organ — will become purified, and the Sattva being purified, > an unbroken memory of the Infinite One, who has been known in His real > nature from scriptures, will result." > > > These two explanations are > apparently conflicting, yet both are true and necessary. The > manipulating and controlling of what may be called the finer body, viz > the mood, are no doubt higher functions than the controlling of the > grosser body of flesh. But the control of the grosser is absolutely > necessary to enable one to arrive at the control of the finer. The > beginner, therefore, must pay particular attention to all such > dietetic rules as have come down from the line of his accredited > teachers; but the extravagant, meaningless fanaticism, which has > driven religion entirely to the kitchen, as may be noticed in the case > of many of our sects, without any hope of the noble truth of that > religion ever coming out to the sunlight of spirituality, is a > peculiar sort of pure and simple materialism. It is neither Jnâna, nor > Bhakti, nor Karma; it is a special kind of lunacy, and those who pin > their souls to it are more likely to go to lunatic asylums than to > Brahmaloka. So it stands to reason that discrimination in the choice > of food is necessary for the attainment of this higher state of mental > composition which cannot be easily obtained otherwise. > > > *The Complete Works of Swami Vivekananda, Volume 3, Bhakti Yoga, The Method and the Means* **A note of caution** Food suggested in any Hatha Yoga book is not accepted by all Yogis. This is because some Yogis think that Hatha yoga is bad for spirituality. It is bad according to Sri Ramakrishna. > > A DEVOTEE: "Sir, what is hathayoga like?" > > > MASTER: "A man practising hathayoga dwells a great deal on his body. > He washes his intestines by means of a bamboo tube through his anus. > He draws ghee and milk through his sexual organ. He learns how to > manipulate his tongue by performing exercises. He sits in a fixed > posture and now and then levitates. All these are actions of prana. A > magician was performing his feats when his tongue turned up and clove > to the roof of his mouth. Immediately his body became motionless. > People thought he was dead. He was buried and remained many years in > the grave. After a long time the grave somehow broke open. Suddenly > the man regained consciousness of the world and cried out, 'Come > delusion! Come confusion!1 (All laugh.) All these are actions of > prana. > > > "**The Vedantists do not accept hathayoga.** There is also rajayoga. > Rajayoga describes how to achieve union with God through the mind — by > means of discrimination and bhakti. **This yoga is good. Hathayoga is > not good.** The life of a man in the Kaliyuga is dependent on food." > > > *The Gospel of Sri Ramakrishna, With the devotees at Dakshineswar (II), December 9, 1883* > > MANILAL: "And what about hathayoga?" > > > MASTER: "The hathayogis identify themselves with their bodies. They > practise internal washing and similar disciplines, and devote > themselves only to the care of the body. Their ideal is to increase > longevity. They serve the body day and night. **That is not good**. > > > *The Gospel of Sri Ramakrishna, The master in various moods, October 2, 1884*
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
The Upanishadic advice is to eat food that keeps your body healthy. Treat food as a type of medicine. > > After saying thrice, ‘I have renounced, I have renounced, I have > renounced’, he shall take up the bamboo staff and don the loin-cloth, > uttering the mantra: ‘Let all beings be devoid of fear. Everything > originates from me. You are my friend and [you] protect me. You are > the strength, my friend. You are the vajra of Indra that killed Vrtra. > Be pleasant to me and remove all my sins.’ **He shall pertake of food as > if it were medicine. He shall eat as if taking medicine. He shall eat > as and when food is obtained.** ‘Oh [disciples], protect brahmacarya, > non-injury, non-possession and truth with care.’ 1 > > > 1 The outer and inner aspects of these qualities are: brahmacarya > (outer) = celibacy, (inner)=the dwelling of the mind on Brahman; > ahimsa=not injuring others, non-injury of oneself; > aparigraha=non-possession of anything other than what is needed for > bare subsistence, non-concern with all but Brahman; > satya=truthfulness, realization of the true nature of the Self. > > > *Arunyupanishad translated by Prof A A Ramanathan* Chandogya Upanishad says that some spiritual aspirant takes a vow to not eat fish and meat for a year or to permanently stop eating non-veg food. The exact shloka is: > > He who thus knows this Yajnayajniya Saman, woven in the limbs of the > body, is endowed with all the limbs, and is not crippled in any limb; > he reaches the full length of life, lives gloriously, becomes great > with offspring and cattle and great also with fame. His holy vow is > that he should not eat fish and meat for a year, or rather, he should > not eat fish and meat at all. > > > *Chandogya Upanishad 2.19.2* Swami Vivekananda has also discussed the question of food for Bhaktas. > > The question of food has always been one of the most vital with the > Bhaktas. Apart from the extravagance into which some of the Bhakti > sects have run, there is a great truth underlying this question of > food. We must remember that, according to the Sankhya philosophy, the > Sattva, Rajas, and Tamas, which in the state of homogeneous > equilibrium form the Prakriti, and in the heterogeneous disturbed > condition form the universe — are both the substance and the quality > of Prakriti. As such they are the materials out of which every human > form has been manufactured, and the predominance of the Sattva > material is what is absolutely necessary for spiritual development. > The materials which we receive through our food into our > body-structure go a great way to determine our mental constitution; > therefore the food we eat has to be particularly taken care of. > However, in this matter, as in others, the fanaticism into which the > disciples invariably fall is not to be laid at the door of the > masters. > > > And this discrimination of food is, after all, of secondary > importance. The very same passage quoted above is explained by > Shankara in his Bhâshya on the Upanishads in a different way by giving > an entirely different meaning to the word Âhâra, translated generally > as food. According to him, "That which is gathered in is Ahara. The > knowledge of the sensations, such as sound etc., is gathered in for > the enjoyment of the enjoyer (self); the purification of the knowledge > which gathers in the perception of the senses is the purifying of the > food (Ahara). The word 'purification-of-food' means the acquiring of > the knowledge of sensations untouched by the defects of attachment, > aversion, and delusion; such is the meaning. Therefore such knowledge > or Ahara being purified, the Sattva material of the possessor it — the > internal organ — will become purified, and the Sattva being purified, > an unbroken memory of the Infinite One, who has been known in His real > nature from scriptures, will result." > > > These two explanations are > apparently conflicting, yet both are true and necessary. The > manipulating and controlling of what may be called the finer body, viz > the mood, are no doubt higher functions than the controlling of the > grosser body of flesh. But the control of the grosser is absolutely > necessary to enable one to arrive at the control of the finer. The > beginner, therefore, must pay particular attention to all such > dietetic rules as have come down from the line of his accredited > teachers; but the extravagant, meaningless fanaticism, which has > driven religion entirely to the kitchen, as may be noticed in the case > of many of our sects, without any hope of the noble truth of that > religion ever coming out to the sunlight of spirituality, is a > peculiar sort of pure and simple materialism. It is neither Jnâna, nor > Bhakti, nor Karma; it is a special kind of lunacy, and those who pin > their souls to it are more likely to go to lunatic asylums than to > Brahmaloka. So it stands to reason that discrimination in the choice > of food is necessary for the attainment of this higher state of mental > composition which cannot be easily obtained otherwise. > > > *The Complete Works of Swami Vivekananda, Volume 3, Bhakti Yoga, The Method and the Means* **A note of caution** Food suggested in any Hatha Yoga book is not accepted by all Yogis. This is because some Yogis think that Hatha yoga is bad for spirituality. It is bad according to Sri Ramakrishna. > > A DEVOTEE: "Sir, what is hathayoga like?" > > > MASTER: "A man practising hathayoga dwells a great deal on his body. > He washes his intestines by means of a bamboo tube through his anus. > He draws ghee and milk through his sexual organ. He learns how to > manipulate his tongue by performing exercises. He sits in a fixed > posture and now and then levitates. All these are actions of prana. A > magician was performing his feats when his tongue turned up and clove > to the roof of his mouth. Immediately his body became motionless. > People thought he was dead. He was buried and remained many years in > the grave. After a long time the grave somehow broke open. Suddenly > the man regained consciousness of the world and cried out, 'Come > delusion! Come confusion!1 (All laugh.) All these are actions of > prana. > > > "**The Vedantists do not accept hathayoga.** There is also rajayoga. > Rajayoga describes how to achieve union with God through the mind — by > means of discrimination and bhakti. **This yoga is good. Hathayoga is > not good.** The life of a man in the Kaliyuga is dependent on food." > > > *The Gospel of Sri Ramakrishna, With the devotees at Dakshineswar (II), December 9, 1883* > > MANILAL: "And what about hathayoga?" > > > MASTER: "The hathayogis identify themselves with their bodies. They > practise internal washing and similar disciplines, and devote > themselves only to the care of the body. Their ideal is to increase > longevity. They serve the body day and night. **That is not good**. > > > *The Gospel of Sri Ramakrishna, The master in various moods, October 2, 1884*
Sanatana Dharma aka Hinduism has 4 sects of people depending on their duty Brahmin (one whose life is of knowledge) ex:- Teacher, priest, doctor, scholar, architect, judge.. Kshatriya (one whose life is of a warrior) ex:- soldier, king, cop, fireman etc., Vaishya (one whose life is of trade) ex:- shop owner, trader, businessman Shudra (one whose life is of labor) ex:- construction worker, engineer, driver etc., Brahmin and Vaishya's profession requires their mental health, alertness and well being to higher than any of their other well being (physical, social etc.,). So the foods suggested are satvik --> vegetarian, dairy, honey and so on. There are a lot of aphrodisiac vegetarian food and they are to be avoided too. It is common knowledge that those who are sexually more active always involve in those thought are less capable of being rational in dealings with those to whom they are sexually attracted. If you are a straight heterosexual business man or a priest with your diet involving a lot of aphrodisiacs then your chances of getting compromised with those of opposite sex are more. vegetarian food which doesn't affect your mood, rationality, alertness etc are recommended. Coffee is vegetarian, mushrooms are vegetarian and so are many drugs. So anything that doesn't affect the natural state and well being of your body and mind is fine. Shudra and Kshatriya's duties require that they prioritize their physical wellbeing. That is why tamasic food (meat, aphrodasiacs, alcohol etc.,) are not forbidden or ill advised for them. If you are following the satvic (hatha, pranayama etc.,) way of yoga then eat satvic food. If you are following the tamasic way of yoga (kundalini, tantric) then you can even go for the tamasic food too but strictly under a guru's guidance.
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[**Yogatattva Upanishad**](https://www.wisdomlib.org/hinduism/book/yogatattva-upanishad-of-krishna-yajurveda/d/doc217055.html) (3rd paragraph ) gives a small glimpse of it with generally healthy vegetarian food is enough for a Yogi > > The proficient in Yoga should abandon the food detrimental to the practice of Yoga. > He should give up salt, mustard; things sour, hot, pungent, or bitter vegetables; asafoetida, > etc., worship of fire, women, walking, bathing at sunrise, emaciation of the body by fasts, etc. > During the early stages of practice, food of milk and ghee is ordained; also food consisting of > wheat, green pulse and red rice are said to favour the progress > > >
As per Ramana Maharshi <http://bhagwan-ramana-maharshi.blogspot.com/2008/12/ramana-maharshi-on-vegetarianism-eating.html> <http://spiritualblossoms.blogspot.com/2010/08/sri-ramana-maharshi-diet.html> > > Question : What about diet? > > Ramana Maharshi : Food affects the mind. > For the practice of any kind of yoga, vegetarianism is absolutely > necessary since it makes the mind more sattvic [pure and harmonious]. > > > Question : Could one receive spiritual illumination while eating flesh > foods? > > Ramana Maharshi : Yes, but abandon them gradually and accustom > yourself to sattvic foods. However, once you have attained > illumination it will make less difference what you eat, as, on a great > fire, it is immaterial what fuel is added. > > > Question : We Europeans are accustomed to a particular diet and a > change of diet affects the health and weakens the mind. Is it not > necessary to keep up one's physical health? > > Ramana Maharshi : Quite > necessary. The weaker the body the stronger the mind grows. > > > Question : In the absence of our usual diet our health suffers and the > mind loses strength. > > Ramana Maharshi : What do you mean by strength of > mind? > > > Question : The power to eliminate worldly attachment. > > Ramana Maharshi > : The quality of food influences the mind. The mind feeds on the food > consumed. > > > Question : Really! Then how can Europeans adjust themselves to sattvic > food only? > > Ramana Maharshi : Habit is only adjustment to the > environment. It is the mind that matters. The fact is that the mind > has been trained to think certain foods tasty and good. The food > material is to be had both in vegetarian and non-vegetarian diet > equally well. But the mind desires such food as it is accustomed to > and considers tasty. > > > Question : Are there restrictions for the realized man with regard to > food? > > Ramana Maharshi : No. He is steady and not influenced by the > food he takes. > > > Question: Is it not killing life to prepare meat diet? > > Ramana Maharshi > : Ahimsa [non-violence] stands foremost in the code of discipline for > the yogis. > > > Question : Even plants have life. > > Ramana Maharshi : So too the slabs > you sit on! > > > Question : May we gradually get ourselves accustomed to vegetarian > food? > > Ramana Maharshi : Yes. That is the way. > > > Question : Is it harmless to continue smoking? > > Ramana Maharshi : No, > for tobacco is a poison. It is better to do without it. It is good > that you have given up smoking. Men are enslaved by tobacco and cannot > give it up. But tobacco only gives a temporary stimulation to which > there must be a reaction with craving for more. It is also not good > for meditation practice. > > > Question : Do you recommend that meat and alcoholic drinks be given > up? > > Ramana Maharshi : It is advisable to give them up because this > abstention is a useful aid for beginners. The difficulty in > surrendering them does not arise because they are really necessary, > but merely because we have become inured by custom and habit to them. > > > Question : Generally speaking, what are the rules of conduct which an > aspirant should follow? > > Ramana Maharshi : Moderation in food, > moderation in sleep and moderation in speech. > > >
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
[**Yogatattva Upanishad**](https://www.wisdomlib.org/hinduism/book/yogatattva-upanishad-of-krishna-yajurveda/d/doc217055.html) (3rd paragraph ) gives a small glimpse of it with generally healthy vegetarian food is enough for a Yogi > > The proficient in Yoga should abandon the food detrimental to the practice of Yoga. > He should give up salt, mustard; things sour, hot, pungent, or bitter vegetables; asafoetida, > etc., worship of fire, women, walking, bathing at sunrise, emaciation of the body by fasts, etc. > During the early stages of practice, food of milk and ghee is ordained; also food consisting of > wheat, green pulse and red rice are said to favour the progress > > >
Sanatana Dharma aka Hinduism has 4 sects of people depending on their duty Brahmin (one whose life is of knowledge) ex:- Teacher, priest, doctor, scholar, architect, judge.. Kshatriya (one whose life is of a warrior) ex:- soldier, king, cop, fireman etc., Vaishya (one whose life is of trade) ex:- shop owner, trader, businessman Shudra (one whose life is of labor) ex:- construction worker, engineer, driver etc., Brahmin and Vaishya's profession requires their mental health, alertness and well being to higher than any of their other well being (physical, social etc.,). So the foods suggested are satvik --> vegetarian, dairy, honey and so on. There are a lot of aphrodisiac vegetarian food and they are to be avoided too. It is common knowledge that those who are sexually more active always involve in those thought are less capable of being rational in dealings with those to whom they are sexually attracted. If you are a straight heterosexual business man or a priest with your diet involving a lot of aphrodisiacs then your chances of getting compromised with those of opposite sex are more. vegetarian food which doesn't affect your mood, rationality, alertness etc are recommended. Coffee is vegetarian, mushrooms are vegetarian and so are many drugs. So anything that doesn't affect the natural state and well being of your body and mind is fine. Shudra and Kshatriya's duties require that they prioritize their physical wellbeing. That is why tamasic food (meat, aphrodasiacs, alcohol etc.,) are not forbidden or ill advised for them. If you are following the satvic (hatha, pranayama etc.,) way of yoga then eat satvic food. If you are following the tamasic way of yoga (kundalini, tantric) then you can even go for the tamasic food too but strictly under a guru's guidance.
29,703
For spiritual progress I want to know the role of food intake. Which type of food is suggested in scriptures for one who want to approach the path of Yoga? In other words, do Shastras recommend or instruct particular foods (to be taken) which helps one's spiritual journey be smooth? Looking for answers from scriptures or from speech/sayings of personalities like Swami Vivekananda who believed to be perfect Yogi.
2018/10/29
[ "https://hinduism.stackexchange.com/questions/29703", "https://hinduism.stackexchange.com", "https://hinduism.stackexchange.com/users/647/" ]
As per Ramana Maharshi <http://bhagwan-ramana-maharshi.blogspot.com/2008/12/ramana-maharshi-on-vegetarianism-eating.html> <http://spiritualblossoms.blogspot.com/2010/08/sri-ramana-maharshi-diet.html> > > Question : What about diet? > > Ramana Maharshi : Food affects the mind. > For the practice of any kind of yoga, vegetarianism is absolutely > necessary since it makes the mind more sattvic [pure and harmonious]. > > > Question : Could one receive spiritual illumination while eating flesh > foods? > > Ramana Maharshi : Yes, but abandon them gradually and accustom > yourself to sattvic foods. However, once you have attained > illumination it will make less difference what you eat, as, on a great > fire, it is immaterial what fuel is added. > > > Question : We Europeans are accustomed to a particular diet and a > change of diet affects the health and weakens the mind. Is it not > necessary to keep up one's physical health? > > Ramana Maharshi : Quite > necessary. The weaker the body the stronger the mind grows. > > > Question : In the absence of our usual diet our health suffers and the > mind loses strength. > > Ramana Maharshi : What do you mean by strength of > mind? > > > Question : The power to eliminate worldly attachment. > > Ramana Maharshi > : The quality of food influences the mind. The mind feeds on the food > consumed. > > > Question : Really! Then how can Europeans adjust themselves to sattvic > food only? > > Ramana Maharshi : Habit is only adjustment to the > environment. It is the mind that matters. The fact is that the mind > has been trained to think certain foods tasty and good. The food > material is to be had both in vegetarian and non-vegetarian diet > equally well. But the mind desires such food as it is accustomed to > and considers tasty. > > > Question : Are there restrictions for the realized man with regard to > food? > > Ramana Maharshi : No. He is steady and not influenced by the > food he takes. > > > Question: Is it not killing life to prepare meat diet? > > Ramana Maharshi > : Ahimsa [non-violence] stands foremost in the code of discipline for > the yogis. > > > Question : Even plants have life. > > Ramana Maharshi : So too the slabs > you sit on! > > > Question : May we gradually get ourselves accustomed to vegetarian > food? > > Ramana Maharshi : Yes. That is the way. > > > Question : Is it harmless to continue smoking? > > Ramana Maharshi : No, > for tobacco is a poison. It is better to do without it. It is good > that you have given up smoking. Men are enslaved by tobacco and cannot > give it up. But tobacco only gives a temporary stimulation to which > there must be a reaction with craving for more. It is also not good > for meditation practice. > > > Question : Do you recommend that meat and alcoholic drinks be given > up? > > Ramana Maharshi : It is advisable to give them up because this > abstention is a useful aid for beginners. The difficulty in > surrendering them does not arise because they are really necessary, > but merely because we have become inured by custom and habit to them. > > > Question : Generally speaking, what are the rules of conduct which an > aspirant should follow? > > Ramana Maharshi : Moderation in food, > moderation in sleep and moderation in speech. > > >
Sanatana Dharma aka Hinduism has 4 sects of people depending on their duty Brahmin (one whose life is of knowledge) ex:- Teacher, priest, doctor, scholar, architect, judge.. Kshatriya (one whose life is of a warrior) ex:- soldier, king, cop, fireman etc., Vaishya (one whose life is of trade) ex:- shop owner, trader, businessman Shudra (one whose life is of labor) ex:- construction worker, engineer, driver etc., Brahmin and Vaishya's profession requires their mental health, alertness and well being to higher than any of their other well being (physical, social etc.,). So the foods suggested are satvik --> vegetarian, dairy, honey and so on. There are a lot of aphrodisiac vegetarian food and they are to be avoided too. It is common knowledge that those who are sexually more active always involve in those thought are less capable of being rational in dealings with those to whom they are sexually attracted. If you are a straight heterosexual business man or a priest with your diet involving a lot of aphrodisiacs then your chances of getting compromised with those of opposite sex are more. vegetarian food which doesn't affect your mood, rationality, alertness etc are recommended. Coffee is vegetarian, mushrooms are vegetarian and so are many drugs. So anything that doesn't affect the natural state and well being of your body and mind is fine. Shudra and Kshatriya's duties require that they prioritize their physical wellbeing. That is why tamasic food (meat, aphrodasiacs, alcohol etc.,) are not forbidden or ill advised for them. If you are following the satvic (hatha, pranayama etc.,) way of yoga then eat satvic food. If you are following the tamasic way of yoga (kundalini, tantric) then you can even go for the tamasic food too but strictly under a guru's guidance.
59,718
Long time ago I heard a word that to the best of my recollection is "plepentry envoy" I have googled a few variants, but "pleopentry envoy", "pelepentry envoy" etc. but nothing similar is coming up. This is a long shot, but the word was suppose to mean something like an envoy that was dispatched by a royal with full mandate without requiring to approve their decisions by the King himself as they would have been acting on behalf of the King ( Of course if later King find out or decided that they did not act as he would then off with their heads). Anyone has any hints on how to chase up this word?
2012/03/01
[ "https://english.stackexchange.com/questions/59718", "https://english.stackexchange.com", "https://english.stackexchange.com/users/6735/" ]
I think you're looking for "plenipotentiary", meaning "full power" from the Latin. <http://en.wikipedia.org/wiki/Plenipotentiary>
As Christi says. It's still in use. The full designation of a British ambassador is 'Her Britannic Majesty's Ambassador Extraordinary and Plenipotentiary'.
59,718
Long time ago I heard a word that to the best of my recollection is "plepentry envoy" I have googled a few variants, but "pleopentry envoy", "pelepentry envoy" etc. but nothing similar is coming up. This is a long shot, but the word was suppose to mean something like an envoy that was dispatched by a royal with full mandate without requiring to approve their decisions by the King himself as they would have been acting on behalf of the King ( Of course if later King find out or decided that they did not act as he would then off with their heads). Anyone has any hints on how to chase up this word?
2012/03/01
[ "https://english.stackexchange.com/questions/59718", "https://english.stackexchange.com", "https://english.stackexchange.com/users/6735/" ]
I think you're looking for "plenipotentiary", meaning "full power" from the Latin. <http://en.wikipedia.org/wiki/Plenipotentiary>
Regarding "hints on how to chase up this word", try a reverse dictionary. For example, entering *[envoy with full mandate](http://www.onelook.com/?w=%2a&loc=revfp2&clue=envoy+with+full+mandate)* at [onelook](http://www.onelook.com/reverse-dictionary.shtml) shows *[plenipotentiary](http://en.wiktionary.org/wiki/plenipotentiary)* as the first entry, while entering just *[envoy](http://www.onelook.com/?w=%2a&loc=revfp2&clue=envoy)* gives *minister plenipotentiary* as the seventh entry. A plenipotentiary is a "person invested with full power, especially as the diplomatic agent of a sovereign state, (originally) charged with handling a certain matter", per wiktionary.