Solutions

Solutions for different problems, might not contain code

Snippets, Solutions

Android Get Application Context

When we are inside an Activity, and we need the application context we can use getApplicationContext()  method. But what if we are not inside an Activity and we need the application context? Well, I will explain in this tutorial how you can get the context of the application outside an Activity. You have to create […]

, , , ,
Snippets, Solutions

ExpandableListView, how to hide indicator

If you use an ExpandableListView and want to hide the group indicator (that arrow that appears on the left) you need to put this in your xml file where the ExpandableListView is created: android:groupIndicator=”@null” Below is a complete example of an xml file: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” > <ExpandableListView android:id=”@+id/expandable_list” android:layout_width=”fill_parent”

,
Snippets, Solutions, Tutorial

Android Add Views into a ViewGroup Dynamically

As Android developer you will surely  need someday to add views dynamically, instead of creating a ListView. I will show you in this tutorial how to do this :) 1. Create a new project and call your activity “MyActivity” 2. Go to res – layout – main.xml and put the following code: <?xml version=”1.0″ encoding=”utf-8″?> <ScrollView

, , , , , , ,
Snippets, Solutions

SQLite Query For Dates Equals To Today

Let’s start with an example: We have a table called StartDate with some dates stored into it as long (milliseconds) like in the image below: To understand better which date represents each record I will write below their dates: 1. Tuesday, February 5, 2013 8:10:17 PM GMT 2. Friday, February 1, 2013 8:10:17 PM GMT 3. Wednesday, February

, , , , ,
Snippets, Solutions

Android HttpResponse content(body) to String

Usually I use the following code to convert a Http response content to String:   BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder responseBuilder = new StringBuilder(); String line = “”; while ((line = in.readLine()) != null) { responseBuilder.append(line); } in.close(); Log.e(“WS RESPONSE”, responseBuilder.toString()); It is not a bad idea but I found over the internet that

, , , ,
sponsored
Exit mobile version