Goal
My Welcomescreen
activity that's the welcome screen when user click the button it fetch the Google News
and return JSON to DisplayMessageActivity here i want to display the JSON like beautifully news feed style...
Achieved
So far I achieved to get the JSON and using the Intent to move response to NewsFeed activity. Now what to do.?
Tried:
I followed Hooking Custom Layout to ListView and I'm here.. their next session are something different so I didn't followed..
DisplayMessageActivity.java
public class DisplayMessageActivity extends ActionBarActivity {
private ListView newsListView;
//private String[] stringArray;
private ArrayAdapter newsItemArrayAdapter;
private static final String DEBUG_TAG = "HTTP";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
//newsItemArrayAdapter = new ArrayAdapter(DisplayMessageActivity.this, android.R.layout.simple_list_item_1, stringArray);
newsItemArrayAdapter = new NewsAdapter(DisplayMessageActivity.this, new String[10]);
newsListView = (ListView) findViewById(R.id.listViewId);
newsListView.setAdapter(newsItemArrayAdapter);
// Get the message from the intent
//Intent intent = getIntent();
//String message = intent.getStringExtra(WelcomescreenActivity.EXTRA_MESSAGE);
//Log.d(DEBUG_TAG, "The response is: " + message);
//setContentView(R.layout.activity_display_message);
}
NewsAdapter.java
public class NewsAdapter extends ArrayAdapter{
private LayoutInflater inflater;
public NewsAdapter(Activity activity, String[] items){
super(activity, R.layout.news_feed, items);
inflater = activity.getWindow().getLayoutInflater();
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
return inflater.inflate(R.layout.news_feed, parent, false);
}
}
news_feed.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:id="@+id/title"
android:text="@string/news_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="19sp" />
</LinearLayout>
Update:
after searching I found this How to parse JSON in Android answer ...
tried and it throws ..
org.json.JSONException: Unterminated string at character 500 of {"responseData": {"results":[{"G
any idea ?