[Solved] Android code without casting

Because if you want to assign a supertype to a specific subtype variable, you need to downcast it to the actual type. Much of the Android framework is from an era before Java generics was available. Is there some better way to approach this? If you only need the View from a findViewById() return, make … Read more

[Solved] Cannot Implicitly Convert int to int[] [closed]

This is because you are trying to assign arrays instead of assigning their members: idArray = Int32.Parse(words[0]); should be idArray[i] = Int32.Parse(words[0]); and so on. Better yet, create EmployeeData class that has individual fields for id, name, dept, and so on, and use it in place of parallel arrays: class EmployeeData { public int Id … Read more

[Solved] Wondering why my app crashes

Looking at your code it seems that you made a typo here: TextView DialogText=(TextView) findViewById(R.id.imageViewDialog); It should be TextView DialogText=(TextView) findViewById(R.id.textViewDialog); or whatever the name of the id for this TextView is. Apart from that, you need to learn to read the messages from the LogCat as they are often very informative. Cleary it says: … Read more

[Solved] Checking int cast from null

If you try and cast null to an int, you will get a NullPointerException. If you want to null-check it, you can use an Integer or Object variable. Integer r = (Integer) map.get(“some_integer”); if (r==null) { // whatever you want to do in this case } else { int result = r; // whatever you … Read more