|
Member 11108789 wrote: I m added them but failed You need to explain what "failed" means. Show the actual code, the values of your variables and any error messages, or a proper description of what happens.
|
|
|
|
|
The code for how I extracted from json:
if((jsonarray.get(0).toString()) != null){
JSONObject jsonobj = new JSONObject(jsonarray.get(0).toString());
Log.e("aptlist", jsonobj.toString());
JSONArray array1= jsonobj.getJSONArray(TAG_APTLIST);
String a1= array1.get(0).toString();
String a2= array1.get(1).toString();
String a3= array1.get(2).toString();
String a4= array1.get(3).toString();
String a5= array1.get(4).toString();
}
Now I want those a1,a2,a3,a4,a5 values in optionsmenu when I click.
I tried as below,but got error as NullPointException
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
getMenuInflater().inflate(R.menu.main, menu);
SubMenu submenu = menu.addSubMenu("Select Apartment");
submenu.add(a1);
Log.e("msg from a1", a1.toString());
submenu.add(a2);
submenu.add(a3);
submenu.add(a4);
submenu.add(a5);
return true;
}
|
|
|
|
|
Member 11108789 wrote: but got error as NullPointException That just means you are trying to use a pointer that has not been initialised, but we cannot guess where it occurs. Use your debugger to trace through the code to identify which line is the problem.
|
|
|
|
|
Hey! how can we extract JSON object if it has a multiple values See below for an example
{"aptName":["AG01","AG02","AG03","AF01","AF02",],},
If it is {"aptName1:"11.765","aptName2:"16.327",} I m able to extract. But I need help for the above one.
and here is my URL: http://nuclious.com/monitoring/QuickAppDataQuery2.php?mobileNo=8123168934..Please check this and let me know how to extract the values. Note:I know how to extract if there is single value.
sunil
|
|
|
|
|
|
Thanks for your reply..
But all I need to extract multiple JSONArray values with only one JSONObject.
It would be great if you give an example for me..
Thanks in Advance!
|
|
|
|
|
|
Hi,
Sir , i am a android developer. please guide me calendar source code for google calendar in android.
|
|
|
|
|
|
I would start here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Hi Guys,
I have been working on an open source MVVM framework for Android, and have just released it on Github. It is a development release, but is quite well documented. Those of you who are addicted to WPF goodness would really love the ability to do the same on Android.
Here it is on Github: RoboMVVM[^]
I am considering writing a tutorial about it on CodeProject soon when I have time for it. Meanwhile, please have a look and tell me what you think.
Regards,
Debdatta Basu
debdatta.basu91@gmail.com
|
|
|
|
|
This is not the place to advertise your work. Please wait until you have written your article and then submit it in the normal way.
|
|
|
|
|
This is not an advertisement. This is a request for comments an suggestions. Thank for yours. I just wish it were more helpful.
|
|
|
|
|
|
Hi
Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram.
repeatTime=(AlarmManager.INTERVAL_DAY*31);
mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi);
Thanks,
Sharath
|
|
|
|
|
You need to add logic to calculate how many days to add, depending on the number of days in the current month. Then each time your application runs it sgould reset the alarm to the new value.
|
|
|
|
|
As you are already (hopefully) aware, hard-coding numbers into your code is a bad idea.
When are you wanting the alarm set for (e.g., the last day of the month)?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hi my code is bellow but it doesnt scroll(everything is for TabHost Not FragmentTabHost) and The tabhost is shrinking and the tab text showing in a second link also.
I want to add Horizontal scroll only for my tabhost.
However we can add swipe able tab. but i don't want this. i want to swipe only the tabhost. not the tab content.
Thanks in advance.
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.app.FragmentTabHost android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/layTab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none" >
<TabWidget
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TabWidget>
</HorizontalScrollView>
</RelativeLayout>
<FrameLayout
android:id="@+id/tabContentsHere"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/layTab"
android:layout_alignParentTop="true" />
</android.support.v4.app.FragmentTabHost>
|
|
|
|
|
Hi... I am using visual studio 2012 for Android App. How to display listview with text and images. please guide me guys.. its urgent....
|
|
|
|
|
Try looking for some samples with Google[^]. And, please, do not tell us it's urgent, we have our own priorities.
|
|
|
|
|
|
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);
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>
}
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);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.fragment1, container, false);
return view;
}
}
}
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.
|
|
|
|
|
According to my counting, the line you have marked is not line 39, as referenced in the error message. However, I suspect that the variable mTabHost has not been set to point to anything. Are you sure you get a valid reference returned in the following statement?
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
|
|
|
|
|
first of all thanks for ur attention.
i have it in "activity_main.axml" :
<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">
And the mTabHost isnot nulll in
mTabHost = FindViewById<FragmentTabHost>(Resource.Id.tabhostN );
Or
Possible to give me and C# xamarin example for doing the same i have done?
any further question?
|
|
|
|
|
Did you actually check the value of this variable at run time? It matters not what you write in your source code, the only way to be sure it works is to check it at the time of error. If it is not that variable that causes the error then it must be one of the others.
I also notice that you have this code within a try/catch block, but you eat the exception. This is really bad practice and leads to situations just such as this. Exceptions provide useful information, so make proper use of them.
|
|
|
|