Skip to content

Instantly share code, notes, and snippets.

@aemxn
aemxn / gist:7596247
Last active Dec 29, 2015
Implementing GetSocialize SDK in Android app - http://aimanbaharum.blogspot.com
View gist:7596247
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/firstview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
View gist:8374076
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
View gist:8374084
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="@+id/category_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
View gist:8374086
public class CategoryActivity extends ListActivity {
ArrayList<HashMap<String, String>> categoryList;
...
@Override
public void onCreate(Bundle savedInstanceState) {
...
categoryList = new ArrayList<HashMap<String, String>>();
...
View gist:8374089
class LoadCategories extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... args) {
return something;
}
View gist:8374093
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(CategoryActivity.this);
pDialog.setMessage("Listing Categories...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
View gist:8374104
protected String doInBackground(String... args){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
String json = jsonParser.makeHttpRequest(URL_CATEGORY, "GET",
params);
// Check your log cat for JSON reponse
Log.d("Categories JSON: ", "> " + json);
View gist:8374109
@Override
protected void onPostExecute(String json) {
try {
categories = new JSONArray(json);
if (categories != null) {
// looping through All albums
for (int i = 0; i < categories.length(); i++) {
JSONObject c = categories.getJSONObject(i);
View gist:8374116
public class CategoryListAdapter extends BaseAdapter {
// class constructor
public CategoryListAdapter(Context context,
ArrayList<HashMap<String, String>> items) {
}
// How many items are in the data set represented by this Adapter.
public int getCount() {
}
View gist:8374119
protected void onCreate(Bundle savedInstanceState) {
...
// get listview
ListView lv = getListView();
lv.setDivider(null);
lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view,