how to set text new line in Toast at center android - center

My Toast have 3 lines, I want line 2 and 3 show center of this toast and set duration to 10 seconds.
How can do it?
Like this picture:

\n inside the string works!!!
Toast.makeText(this, "line1\nLine2", Toast.LENGTH_SHORT).show();

You can customize Toast class. Here is example:
Context context=getApplicationContext();
LayoutInflater inflater=getLayoutInflater();
View customToastroot =inflater.inflate(R.layout.YOUR_TOAST_LAYOUT, null);
Toast customtoast=new Toast(context);
customtoast.setView(customToastroot);
customtoast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL,0, 0);
customtoast.setDuration(Toast.LENGTH_LONG);
customtoast.show();
For more details tutorials visit here and here

Toast.makeText(this,"YOUR MESSAGE",
+"\n"+
"Your other message",
Toast.Lenght_long).show();
Each time you add a line with
+"\n"+

Related

chrome selection text to keep formatting

I have a context menu, so when you selection some text from a page they can send to my extension. I am using
var child1 = chrome.contextMenus.create(
{"title": "Send To Box" , contexts:["selection"], "parentId": id, "id":"box", "contexts":[context], "onclick": sendToMyBox});
And in my sendToMyBox
function sendToMyBox(info, tab)
{
if (info.menuItemId == "box")
{
mainData = info.selectionText;
}
}
So the issue is selectionText is missing all the formatting. What ever selected its coming as a single line text, is there anyway I can get the current format from the selected. Basically I want to keep all the new lines tabs, etc...
Thanks
I think maybe you can get the html element first (you can achieve that by register a mouse event, then get event.target), then use
element.innerHTML
to get the rich text.

Different Colors in primefaces bar chart

I would like to show primefaces barchart with different colors for each bar. the most close I got is like the image:
I would like to have different color those bars, like green for "on time", yellow for "warning " and red for "overdue"
I tried to used model.setSeriesColors("58BA27,FFCC33,F74A4A,F52F2F,A30303");
but if i do that each bar should be a new series, therefore I won't be able to show the labels as I wish (like the image), I got this..
last, how can I make it show 0,1,2,3 (integers) instead repeating 0_0_0_1_1_1_2_2_2 like the image 1 :/
thanks
I solved the problem by my own reading this jplot documentation, I'm posting here hope it can help someone...
for somehow, adding extender in the tag is not working for me, I have to put it via java code:
barModel.setSeriesColors("58BA27,FFCC33,F74A4A,F52F2F,A30303");
barModel.setExtender("chartExtender");
then javascript inside
<h:outputScript>
function chartExtender() {
// this = chart widget instance
// this.cfg = options
this.cfg.seriesDefaults.rendererOptions.varyBarColor = true;
}
</h:outputScript>
and done!
I'm new here, so I unfortunately cannot add a comment to your answer.
It worked for me too.
Some clarifications for other readers:
Be sure to put the <h:outputScript> under your <p:chart... like:
<p:chart type="bar" model="#{bean.someModel}">
<h:outputScript>
function chartExtender() {
// this = chart widget instance
// this.cfg = options
this.cfg.seriesDefaults.rendererOptions.varyBarColor = true;
}
</h:outputScript>
</p:chart>
The "extender" -Tag has been removed in Primefaces 5:
see this answer

Eclipse FormEditor button as page title

I implemented my custom FormEditor. Now I want to let user create new FormPages (a.k.a. tabs) in this editor like it is made e.g. in Chrome tabs. How to insert a "new tab" button near the titles of existing FormPages?
Thank you in advance!
UPD:
I added a FormPage with title "+" and insert new page in listener to PageChangedEvent.
You can add actions to the toolbar at the top right of a FormPage like this:
ScrolledForm form = managedForm.getForm();
IToolBarManager manager = form.getToolBarManager();
Action myAction = new Action("My Action") {
public void run() {
// TODO your action
}
};
myAction.setToolTipText("tooltip text");
myAction.setImageDescriptor(action image descriptor);
manager.add(myAction);

Message alert in windows phone 8

How to implement a message box like a alert box when button gets clicked or tiles get tapped.
also messagebox or alertbox contain buttons into my windows phone 8 application.
To show an alert you can use,
MessageDialog msgbox = new MessageDialog("Message to be displayed.");
await msgbox.ShowAsync();
Just take a look at the msdn.
There you can get an example and further details about MessageBox.Show Method (String, String, MessageBoxButton):
MessageBoxResult result =
MessageBox.Show("Would you like to see the simple version?",
"MessageBox Example", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
MessageBox.Show("No caption, one button.");
}
Or a overview about the whole MessageBox class.

how to search a name of text-file c# windows phone

I'm a newbie wp dev. I want to create a many text file name like 1.text 2.text 3.text ......1760.text and I want user to type the number in text box then click the button and the result is read that typed number.text. how can I do it ? please help
you can try this method:
1. put these txt-files into a path,like:TxtFiles/1.txt,2.txt...
2. when user type the number and click button, execute a method to combine file-path and read the file. and you should check the number first.
StreamResourceInfo resourceInfo = Application.GetResourceStream(new Uri(string.Format("yourFilePath/{0}.txt",userTypedNumber), UriKind.Relative));
using (StreamReader reader = new StreamReader(resourceInfo.Stream))
{
yourContentControl.Text = reader.ReadToEnd();
reader.Close();
}