samedi 27 juin 2015

Creating Vertical ScrollView inside ViewPager

I am trying to add a scrollView inside my ViewPager so I can scroll left and right as well as down if the page becomes full. As of now, I am dynamically adding views to my ViewPager:

Fragment Page in ViewPager:

ScrollView is not being inserted since i must remove the parent view.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mainView = View.inflate(getActivity(), R.layout.fragment_profile_personal_records, null);
    LinearLayout mainLayout = (LinearLayout) mainView.findViewById(R.id.layoutPR);
    ScrollView scrollView = new ScrollView(getActivity());
    scrollView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    for(int i = 0; i < 3; i++){
        LinearLayout rowLayout = (LinearLayout) mainView.inflate(getActivity(), R.layout.row_personal_records, null);
        mainLayout.addView(rowLayout);
    }
    scrollView.addView(mainLayout, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    return scrollView;
}

XML for Fragment:`

    <LinearLayout
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/layoutPR"
    android:orientation="vertical"
    tools:context="test.test.test.fragment">
</LinearLayout>

Container that contains viewPager:

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_below="@id/mainLayout">

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/vpPager"
        android:scrollbars="vertical">

        <android.support.v4.view.PagerTabStrip
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/pagerHeader"
            android:layout_gravity="top"
            android:paddingBottom="5dp"
            android:textColor="#000000"
            android:paddingTop="5dp">
        </android.support.v4.view.PagerTabStrip>

    </android.support.v4.view.ViewPager>

</LinearLayout>

I have looked on the internet for answers but haven't come across anything that will insert a vertical scrollbar inside a viewPager that the view inside is created dynamically/programitcally and without xml

Crosswalk 14 - orientation is not changing

In my app build on crosswalk 14 and ionic there is no orientation change. if You rotate device - no change. My congif.xml file

<?xml version='1.0' encoding='utf-8'?>
<widget id="pl.polskieszlaki.PolskieSzlaki" android-versionCode="6" version="2.0.1"  android-installLocation="preferExternal" xmlns="http://ift.tt/18Fk3Vk" xmlns:cdv="http://ift.tt/1cHnIYX">
    <name>Polskie Szlaki</name>
    <description>Flagowa aplikacja portalu PolskieSzlaki.pl. Znajdziesz tutaj opisy tysięcy atrakcji z całej Polski
    </description>
    <author email="biuro@polskieszlaki.pl" href="http://ift.tt/1Il40m5">Łukasz Piernikarczyk</author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" version="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <preference name="SplashScreen" value="screen"/>
    <preference name="SplashScreenDelay" value="3000"/>
    <preference name="android-minSdkVersion" value="17"/>
    <preference name="android-targetSdkVersion" value="19"/>
    <preference name="xwalkVersion" value="14" />
    <preference name="Orientation" value="default" />
    <platform name="android">
        <icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
        <icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
        <icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
        <icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
        <icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
        <icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
        <splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
        <splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
        <splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
        <splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
        <splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
        <splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
        <splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
        <splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
        <splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
        <splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
        <splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
        <splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
    </platform>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
</widget>

And AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:installLocation="preferExternal" android:versionCode="6" android:versionName="2.0.1" package="pl.polskieszlaki.PolskieSzlaki" xmlns:android="http://ift.tt/nIICcg">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBINjjNZBV2_yrk_L6vJfmLYshvzdXMBO4" />
        <activity android:name="com.keyes.youtube.OpenYouTubePlayerActivity" android:screenOrientation="landscape" />
    </application>
    <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
</manifest>

Without crosswalk everything works great.

My codrova plugins:

com.bunkerpalace.cordova.YoutubeVideoPlayer 1.0.1 "CordovaYoutubeVideoPlayer"
com.google.playservices 19.0.0 "Google Play Services for Android"
cordova-plugin-crosswalk-webview 1.2.0 "Crosswalk WebView Engine"
cordova-plugin-google-analytics 0.7.2 "Google Universal Analytics Plugin"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-whitelist 1.0.0 "Whitelist"
nl.x-services.plugins.socialsharing 4.3.19-dev "SocialSharing"
nl.x-services.plugins.toast 2.1.1 "Toast"
org.apache.cordova.dialogs 0.3.0 "Notification"
org.apache.cordova.geolocation 0.3.12 "Geolocation"
org.apache.cordova.globalization 0.3.4 "Globalization"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.network-information 0.2.15 "Network Information"
org.pushandplay.cordova.apprate 1.1.7 "AppRate"
plugin.google.maps 1.2.5 "phonegap-googlemaps-plugin"
plugin.http.request 1.0.4 "phonegap-http-request"

App crashes on orientation change after I change my listview in same activity

My app starts in the MainActivity and uses a loader and custom adapter to populate my listview with the users' favourites. The data will persist over the orientation change.

But then if the user performs a search the listview in the MainActivity is repopulated with the new data. That works fine. But now, an orientation change crashes my app.

I'm also confused whether I have to explicitly save my instance before an orientation change or if Android does it for me. And if I have to do it explicitly would it be better to just perform the database query again instead?

package must.beunique.recipebook;

import java.io.File;

import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.CursorAdapter;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ListView;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.widget.AdapterView.OnItemClickListener;
import android.view.View;
import android.widget.SearchView;
import android.util.Log;

public class MainActivity extends FragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> {

    private CursorAdapter dataAdapter;
    private String query = null;

    private static final String DATABASE_PATH = "/data/data/must.beunique.recipebook/databases/RECIPES";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.w("DEBUG", "MainActivity - onCreate()");
        super.onCreate(savedInstanceState);

        setContentView(R.layout.query_results);     



            File database = this.getDatabasePath(DATABASE_PATH);
            if (database.exists()) {    


                // Get the intent, verify the action and get the query
                Intent intent = getIntent();
                Bundle extras = intent.getExtras();

                // search query in intent
                if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
                    query = intent.getStringExtra(SearchManager.QUERY);
                }         
                // browse all...
                else if(extras!=null){
                    if(extras.containsKey("browse")){
                        query = "";
                    }
                }                                           

                Log.w("DEBUG", "starting adapter");
                int[] to = new int[] { R.id.text1 };
                String[] columns = new String[]{ "name" };
                dataAdapter = new CustomAdapter(this, R.layout.text_view, null, columns, to, Adapter.NO_SELECTION);
                ListView listView = (ListView) findViewById(android.R.id.list);
                listView.setAdapter(dataAdapter);

                Log.w("DEBUG", "listView.setAdapter(dataAdapter)");
                listView.setOnItemClickListener(new OnItemClickListener()
                {

                    @Override
                    public void onItemClick(AdapterView<?> arg0, View view,
                            int position, long id) {
                        Intent intent = new Intent(getBaseContext(), Recipe.class);
                        intent.putExtra("must.beunique.recipebook._id", (int)id);
                        startActivity(intent);
                    }   
                }       );
                Log.w("DEBUG", "end adapter");
                getSupportLoaderManager().initLoader(0, null, this);

            }
            else{
                new SyncRecipes(this).execute(); 
            } 

        Log.w("DEBUG", "end onCreate()");
    }

    public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
        Log.w("DEBUG", "onCreateLoader()");
        if(query==""){
            // empty search, return all
            return new CursorLoader(this, Uri.parse("content://must.beunique.recipebook.data/"+DataProvider.BRW), null, null, null, null);          
        }
        else if(query == null){
            return new CursorLoader(this, Uri.parse("content://must.beunique.recipebook.data/"+DataProvider.FAV), null, null, null, null);
        }
        else{
            // term search, return relevant
            return new CursorLoader(this, Uri.parse("content://must.beunique.recipebook.data/"+DataProvider.TRM+"/"+query), null, null, null, null);
        }
    }

    public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
        Log.w("DEBUG", "onLoadFinished()");
        dataAdapter.swapCursor(cursor);
    }

    public void onLoaderReset(Loader<Cursor> cursorLoader) {
        dataAdapter.swapCursor(null);
    }

    protected void onDestroy(Bundle savedInstanceState) {
        super.onDestroy();
    }

    @Override
    public void onSaveInstanceState(Bundle InstanceState) {
        super.onSaveInstanceState(InstanceState);
        InstanceState.putString("query", query);
        dataAdapter.swapCursor(null);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu, menu);
         // Associate searchable configuration with the SearchView
        SearchManager searchManager =
               (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView =
                (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setSearchableInfo(
                searchManager.getSearchableInfo(getComponentName()));
        Log.w("DEBUG", "end - onCreateOptionsMenu()");
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu){
        Log.w("DEBUG", "onPrepareOptionsMenu()");
            menu.findItem(R.id.favourite).setVisible(false);
            menu.findItem(R.id.favourite).setEnabled(false);
            menu.findItem(android.R.id.home).setVisible(true);
            menu.findItem(android.R.id.home).setEnabled(true);
        Log.w("DEBUG", "end - onPrepareOptionsMenu()");
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
            case android.R.id.home:            
                Intent intent = new Intent(this, MainActivity.class);
                startActivity(intent);            
                return true; 
            case R.id.search:
                onSearchRequested();
                return true;
            case R.id.browse:
                Intent bintent = new Intent(this, MainActivity.class);
                bintent.putExtra("browse", true);
                startActivity(bintent);;
                return true;            
            case R.id.sync:
                new SyncRecipes(this).execute();
                return true;
            case R.id.rebuild:
                Boolean Qdeleted = this.deleteDatabase(DATABASE_PATH);
                new SyncRecipes(this).execute();
                return true;                                
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}

I can't interpret the logcat

06-27 22:15:52.421: W/DEBUG(29310): MainActivity - onCreate()
06-27 22:15:52.531: D/AbsListView(29310): Get MotionRecognitionManager
06-27 22:15:52.551: W/DEBUG(29310): starting adapter
06-27 22:15:52.556: W/DEBUG(29310): listView.setAdapter(dataAdapter)
06-27 22:15:52.556: W/DEBUG(29310): end adapter
06-27 22:15:52.561: W/DEBUG(29310): onCreateLoader()
06-27 22:15:52.566: W/DEBUG(29310): end onCreate()
06-27 22:15:52.691: D/libEGL(29310): loaded /system/lib/egl/libEGL_mali.so
06-27 22:15:52.696: D/libEGL(29310): loaded /system/lib/egl/libGLESv1_CM_mali.so
06-27 22:15:52.701: D/libEGL(29310): loaded /system/lib/egl/libGLESv2_mali.so
06-27 22:15:52.706: E/(29310): Device driver API match
06-27 22:15:52.706: E/(29310): Device driver API version: 23
06-27 22:15:52.706: E/(29310): User space API version: 23 
06-27 22:15:52.706: E/(29310): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Mar 21 13:52:50 KST 2014 
06-27 22:15:52.771: D/OpenGLRenderer(29310): Enabling debug mode 0
06-27 22:15:52.781: W/DEBUG(29310): onCreateOptionsMenu()
06-27 22:15:52.816: W/DEBUG(29310): end - onCreateOptionsMenu()
06-27 22:15:52.816: W/DEBUG(29310): onPrepareOptionsMenu()
06-27 22:15:52.816: W/DEBUG(29310): end - onPrepareOptionsMenu()
06-27 22:15:52.856: W/DEBUG(29310): onLoadFinished()
06-27 22:15:52.856: W/DEBUG(29310): end - onLoadFinished()
06-27 22:15:56.846: D/AbsListView(29310): Get MotionRecognitionManager
06-27 22:15:58.281: D/AbsListView(29310): onDetachedFromWindow
06-27 22:15:58.291: W/DEBUG(29310): MainActivity - onCreate()
06-27 22:15:58.346: D/AbsListView(29310): Get MotionRecognitionManager
06-27 22:15:58.351: W/DEBUG(29310): starting adapter
06-27 22:15:58.351: W/DEBUG(29310): listView.setAdapter(dataAdapter)
06-27 22:15:58.351: W/DEBUG(29310): end adapter
06-27 22:15:58.351: W/DEBUG(29310): onCreateLoader()
06-27 22:15:58.351: W/DEBUG(29310): end onCreate()
06-27 22:15:58.486: W/DEBUG(29310): onCreateOptionsMenu()
06-27 22:15:58.516: W/DEBUG(29310): end - onCreateOptionsMenu()
06-27 22:15:58.516: W/DEBUG(29310): onPrepareOptionsMenu()
06-27 22:15:58.516: W/DEBUG(29310): end - onPrepareOptionsMenu()
06-27 22:15:58.746: W/DEBUG(29310): onLoadFinished()
06-27 22:15:58.746: W/DEBUG(29310): end - onLoadFinished()
06-27 22:15:58.981: W/DEBUG(29310): onSaveInstanceState()
06-27 22:16:00.846: W/DEBUG(29310): onSaveInstanceState()
06-27 22:16:00.856: D/AbsListView(29310): onDetachedFromWindow
06-27 22:16:01.101: W/DEBUG(29310): MainActivity - onCreate()
06-27 22:16:01.166: D/AbsListView(29310): Get MotionRecognitionManager
06-27 22:16:01.171: W/DEBUG(29310): starting adapter
06-27 22:16:01.171: W/DEBUG(29310): listView.setAdapter(dataAdapter)
06-27 22:16:01.171: W/DEBUG(29310): end adapter
06-27 22:16:01.171: W/DEBUG(29310): end onCreate()
06-27 22:16:01.171: W/DEBUG(29310): onLoadFinished()
06-27 22:16:01.171: W/DEBUG(29310): end - onLoadFinished()
06-27 22:16:01.221: D/AndroidRuntime(29310): Shutting down VM
06-27 22:16:01.221: W/dalvikvm(29310): threadid=1: thread exiting with uncaught exception (group=0x418b4c08)
06-27 22:16:01.231: E/AndroidRuntime(29310): FATAL EXCEPTION: main
06-27 22:16:01.231: E/AndroidRuntime(29310): Process: must.beunique.recipebook, PID: 29310
06-27 22:16:01.231: E/AndroidRuntime(29310): android.view.InflateException: Binary XML file line #31: Error inflating class <unknown>
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.createView(LayoutInflater.java:626)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at com.android.internal.widget.ActionBarContextView.initClose(ActionBarContextView.java:330)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at com.android.internal.widget.ActionBarContextView.onConfigurationChanged(ActionBarContextView.java:185)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.View.dispatchConfigurationChanged(View.java:8599)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1105)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1110)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1110)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewGroup.dispatchConfigurationChanged(ViewGroup.java:1110)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewRootImpl.updateConfiguration(ViewRootImpl.java:3441)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3612)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.os.Looper.loop(Looper.java:146)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.app.ActivityThread.main(ActivityThread.java:5593)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at java.lang.reflect.Method.invokeNative(Native Method)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at java.lang.reflect.Method.invoke(Method.java:515)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at dalvik.system.NativeStart.main(Native Method)
06-27 22:16:01.231: E/AndroidRuntime(29310): Caused by: java.lang.reflect.InvocationTargetException
06-27 22:16:01.231: E/AndroidRuntime(29310):    at java.lang.reflect.Constructor.constructNative(Native Method)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.view.LayoutInflater.createView(LayoutInflater.java:600)
06-27 22:16:01.231: E/AndroidRuntime(29310):    ... 23 more
06-27 22:16:01.231: E/AndroidRuntime(29310): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=24; index=27
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.content.res.StringBlock.get(StringBlock.java:65)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:459)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:721)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.content.res.TypedArray.getString(TypedArray.java:125)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.widget.TextView.<init>(TextView.java:1509)
06-27 22:16:01.231: E/AndroidRuntime(29310):    at android.widget.TextView.<init>(TextView.java:908)
06-27 22:16:01.231: E/AndroidRuntime(29310):    ... 26 more

LAYOUT XML's

query_results.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    style = "@style/Activity"
>   
    <ListView 
        android:id="@android:id/list"
        style = "@style/ListView"       
    />          

</LinearLayout>

text_view.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:orientation="vertical"
>       

    <TextView 
         style = "@style/Item"
         android:id="@+id/text1"
         android:hint="@string/no_recipes" 
         android:maxLines="1"    /> 

</LinearLayout>

Is it possible to change the color/style of a single day in an Android calendar view?

I have seen a few other questions but they are either old or unanswered.

Add event to Week view library

I'm using this library : http://ift.tt/1rtrYBv And I want that when I click on an empty space, an event will show up on the calendar, but it doesnt..The event is added to events variable. but you cant see it in the calendar
here is my code:

      List<WeekViewEvent> events = new ArrayList<WeekViewEvent>();


   mWeekView.setEmptyViewClickListener(new WeekView.EmptyViewClickListener() {
            @Override
            public void onEmptyViewClicked(Calendar calendar) {

                Calendar cal2 = (Calendar) calendar.clone();
                cal2.add(Calendar.HOUR, 1);
                WeekViewEvent event = new WeekViewEvent(1,"Hello", calendar, cal2);
                event.setColor(getActivity().getResources().getColor(R.color.event_color_01));
                events.add(event);

                events.add(event);
                onMonthChange(2015,5);
            }
        });


 @Override
    public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {
    return events;
}

Getting back object from child activiy in Android

I have a main_activity that starts a child Activity via Intent.

I know about methods getStringExtra(string), or getBooleanExtra(string) etc. that we call in onActivityResult; But they all return a primitive data... How can I get an object from a user-defined class from the child activity?

Thanks, and this is my first question here! :) kinda too late...

OnItemSelect Spinner Duplicating a Record in Android

strong text

Can any one tell me Why my Record is duplicating on per item selected in Android Spinner..

OnCreate() method

path_spinner = (Spinner) findViewById(R.id.spinner_path);
        path_spinner.post(new Runnable() {
            @Override
            public void run() {

                path_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                    @Override
                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                        if (path_spinner.getSelectedItemPosition() > 0) {
                            getitemno = path_spinner.getSelectedItemPosition();
                            getposition = getitemno;

                            new AlgoApiNetCheck().execute();

                            if (path_spinner!=null && path_spinner.getSelectedItemPosition()==0)
                            {
                                new AlgoApiNetCheck().execute();
                            }

                            Log.d("Item Position", String.valueOf(getitemno));
                        }
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> parent) {

                    }
                });
            }
        });

Async Class OnPostMethod

 if (!check) {
            adapter = new ArrayAdapter<String>(MapLocationActivity.this,
                    android.R.layout.simple_spinner_item, get_path);
            Log.d("Counter", get_path.toString());
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            path_spinner.setAdapter(adapter);
        }

How to prevent My Spinner to stop a Duplicating My Record