[Solved] NetworkOnMainThread Error

http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html. NetworkOnMainThread occurs because you might me doing netowrk related operation on the main UI Thread. You have to make network related operation in the background thread and updata ui on the ui thread. You can use a asycntask. http://developer.android.com/reference/android/os/AsyncTask.html class TheTask extends AsyncTask<Void,Void,Void> { protected void onPreExecute() { super.onPreExecute(); //display progressdialog. } protected void … Read more

[Solved] A function that returns the number of even numbers of an array

One actually does never want to mix computation logic with whatever kind of output code. In addition one could make use of Array.prototype.filter and a precise filter condition which does target odd and/or even number values … something similar to the next provided example code … function getEvenCount(list) { return list.filter(item => (typeof item === … Read more

[Solved] How do you count the values in a 2d list [closed]

You can use list comprehensions to do this. In this case, you can check the len of each sublist, and use that to filter out which sublists you want to keep/discard. >>> df = [[2,4,6,7],[3,4,],[2,4,6,8,12,24],[3,5,7,333,450],[4,20]] >>> [i for i in df if len(i) > 3] [[2, 4, 6, 7], [2, 4, 6, 8, 12, 24], … Read more

[Solved] Regular expression for accept only 1 occurrence of “space” and “single quote” character among letters [closed]

quote | space || ——-+——-++—– 0 | 0 || ^[a-z]*$ 0 | 1 || ^[a-z]* [a-z]*$ 1 | 0 || ^[a-z]*'[a-z]*$ 1 | 1 || ^[a-z]* [a-z]*'[a-z]*$ or ^[a-z]*'[a-z]* [a-z]*$ Eg. final Pattern regex = Pattern .compile(“^([a-z]*|[a-z]* [a-z]*|[a-z]*'[a-z]*|[a-z]* [a-z]*'[a-z]*|[a-z]*'[a-z]* [a-z]*)$”, CASE_INSENSITIVE); for(String x: asList(“”, “‘”, ” “, “‘ ‘”, ” a “, “p%q”, “aB cd’Ef”, … Read more

[Solved] How to make an auto increment number based on a year

I have figured it out myself and thank you for the down votes public class SerialNumber { private static readonly MyDbContext DbContext = new MyDbContext(); public static string SrNo() { var sn = DbContext.PrimaryForms.ToList().Last().FormDescription; var array = sn.Split(“https://stackoverflow.com/”); if (int.Parse(array[0]) == DateTime.Today.Year) { return array[0] + “https://stackoverflow.com/” + (int.Parse(array[1]) + 1); } return (int.Parse(array[0]) + … Read more

[Solved] can anyone please how to make pointing corner background? [closed]

i just did not find the appropriate duplicate, but it is a duplicate and deserves to be closed for a better readability of the q/a . You could probably use gradient backgrounds: header { padding:0em 1em 4em; margin:1em; background:linear-gradient(to bottom, transparent 2em, rgb(58, 64, 125) 2em) } div {background:rgb(238, 123, 45);position:relative;padding:1em ;color:white;} div:after { content:”; … Read more

[Solved] Insert into Temp Table from SQL Dynamic Results

all what i had to do is add this: ‘ into ##myTempTable DECLARE @DynamicPivotQuery AS NVARCHAR(MAX) DECLARE @ColumnName AS NVARCHAR(MAX) –Get distinct values of the PIVOT Column SELECT @ColumnName = ISNULL(@ColumnName + ‘,’,”) + QUOTENAME([month]) FROM (SELECT DISTINCT [Month] FROM MyTable) AS [Month] order by [month] –Prepare the PIVOT query using the dynamic SET @DynamicPivotQuery … Read more