Click here to Skip to main content
14,976,940 members
Home / Discussions / Android
   

Android

 
Questionhow to set alarm to repeat monthly Pin
sharath198410-Sep-14 23:55
Membersharath198410-Sep-14 23:55 
AnswerRe: how to set alarm to repeat monthly Pin
Richard MacCutchan11-Sep-14 0:38
mveRichard MacCutchan11-Sep-14 0:38 
QuestionRe: how to set alarm to repeat monthly Pin
David Crow19-Sep-14 4:33
MemberDavid Crow19-Sep-14 4:33 
QuestionFragmentTabHost with scrolling tabs Horizontal (xamarin-C#) Pin
jojoba2010-Sep-14 1:29
Memberjojoba2010-Sep-14 1:29 
QuestionAndriod Listview using c# Pin
Vinojegan8-Sep-14 3:21
MemberVinojegan8-Sep-14 3:21 
AnswerRe: Andriod Listview using c# Pin
Richard MacCutchan8-Sep-14 5:07
mveRichard MacCutchan8-Sep-14 5:07 
AnswerRe: Andriod Listview using c# Pin
Dominic Burford15-Sep-14 2:21
professionalDominic Burford15-Sep-14 2:21 
QuestionFragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 0:17
Memberjojoba208-Sep-14 0:17 
I am using FragmentTabHost in xamarin C# and i get error in :

mTabHost.AddTab(spec);

and the whole project is :(Part that you may need)

Activity 2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Content.PM;
using Android.Support.V4.App;
 
 
namespace ANRestaurant.Forms
{
    [Activity(Label = "ANRestaurant", MainLauncher = true, Icon = "@drawable/icon", ScreenOrientation = ScreenOrientation.Portrait)]
 
 
    public class Activity2 : FragmentActivity
    {
        FragmentTabHost mTabHost;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
 
 
            SetContentView(Resource.Layout.activity_main);
            try
            {
                mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN  );
                Intent intent;
                intent = new Intent(this, typeof(Fragment1));
                intent.AddFlags(ActivityFlags.NewTask);
                //mTabHost.Setup(this, SupportFragmentManager, Resource.Id.tabFrameLayout);
 
 
                TabHost.TabSpec spec;
                spec = mTabHost.NewTabSpec("artists");
                spec.SetIndicator("Artists", Resources.GetDrawable(Resource.Drawable.tab_icon1)  );
                spec.SetContent(intent);
                mTabHost.AddTab(spec);   <code><big>======>Here the error occered!</big></code> 
                //mTabHost.AddTab(
                //        mTabHost.NewTabSpec("tab2").SetIndicator("Tab 2", null),
                //       intent, null);
                //mTabHost.addTab(
                //        mTabHost.newTabSpec("tab2").setIndicator("Tab 2", null),
                //        FragmentTab.class, null);
                //mTabHost.addTab(
                //        mTabHost.newTabSpec("tab3").setIndicator("Tab 3", null),
                //        FragmentTab.class, null);
            }
            catch (Exception ex)
            {
 
 
            }
        }
    }
}


activity_main.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhostN"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TabWidget
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:orientation="horizontal" />
        <FrameLayout
            android:id="@+id/tabFrameLayout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>
</android.support.v4.app.FragmentTabHost>


Fragment1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
 
 
namespace ANRestaurant.Forms
{
    public class Fragment1 : Fragment
    {
 
 
        
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
 
 
            // Create your fragment here
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.fragment1, container, false);
           return view;
             //return base.OnCreateView(inflater, container, savedInstanceState);
        }
    }
}


fragment1.axml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#AA1111">
    <TextView
        android:id="@+id/txtF"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="This is Tab 1"
        android:textSize="20sp"
        android:textColor="#dddddd"
        android:layout_centerInParent="true" />
</RelativeLayout>


<big>And THE ERROR IS :</big>

{Java.Lang.NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.
  at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00063] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:507 
  at Android.Widget.TabHost.AddTab (Android.Widget.TabSpec tabSpec) [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/platforms/android-12/src/generated/Android.Widget.TabHost.cs:801 
  at ANRestaurant.Forms.Activity2.OnCreate (Android.OS.Bundle bundle) [0x00079] in e:\Home\Herman resturant Android\Source\ANRestaurant\ANRestaurant\Forms\Act  ivity2.cs:39 
  --- End of managed exception stack trace ---
java.lang.NullPointerException
    at android.widget.TabHost.addTab(TabHost.java:236)
    at anrestaurant.forms.Activity2.n_onCreate(Native Method)
    at anrestaurant.forms.Activity2.onCreate(Activity2.ja  va:28)
    at android.app.Activity.performCreate(Activity.java:5  104)
    at android.app.Instrumentation.callActivityOnCreate(I  nstrumentation.java:1080)
    at android.app.ActivityThread.performLaunchActivity(A  ctivityThread.java:2144)
    at android.app.ActivityThread.handleLaunchActivity(Ac  tivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThre  ad.java:141)
    at android.app.ActivityThread$H.handleMessage(Activit  yThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99  )
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.jav  a:5041)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCa  ller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit  .java:560)
    at dalvik.system.NativeStart.main(Native Method)
}


modified 8-Sep-14 6:25am.

AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 0:58
mveRichard MacCutchan8-Sep-14 0:58 
QuestionRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 3:52
Memberjojoba208-Sep-14 3:52 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 4:48
mveRichard MacCutchan8-Sep-14 4:48 
QuestionRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 4:55
Memberjojoba208-Sep-14 4:55 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 5:03
mveRichard MacCutchan8-Sep-14 5:03 
QuestionRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 5:16
Memberjojoba208-Sep-14 5:16 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 5:40
mveRichard MacCutchan8-Sep-14 5:40 
QuestionRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 6:54
Memberjojoba208-Sep-14 6:54 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 7:22
mveRichard MacCutchan8-Sep-14 7:22 
QuestionRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba208-Sep-14 10:17
Memberjojoba208-Sep-14 10:17 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan8-Sep-14 20:33
mveRichard MacCutchan8-Sep-14 20:33 
AnswerRe: FragmentTabHost in VS2013 - xamarin C# Pin
jojoba209-Sep-14 3:33
Memberjojoba209-Sep-14 3:33 
GeneralRe: FragmentTabHost in VS2013 - xamarin C# Pin
Richard MacCutchan9-Sep-14 5:20
mveRichard MacCutchan9-Sep-14 5:20 
Questionprint directly to printer on server (xamarin C#) Pin
jojoba205-Sep-14 1:46
Memberjojoba205-Sep-14 1:46 
SuggestionRe: print directly to printer on server (xamarin C#) Pin
Richard MacCutchan5-Sep-14 2:37
mveRichard MacCutchan5-Sep-14 2:37 
QuestionRe: print directly to printer on server (xamarin C#) Pin
jojoba205-Sep-14 7:22
Memberjojoba205-Sep-14 7:22 
AnswerRe: print directly to printer on server (xamarin C#) Pin
Richard MacCutchan5-Sep-14 7:25
mveRichard MacCutchan5-Sep-14 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.