Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
DataGridView first use i got error
posted

hi 

i got error in first use of data grid in android .

this is my code 

public class TestData extends ArrayList<TestDataItem> {

Random r = new Random();

public TestData() {
Populate();
}

public void Populate() {
Random r = new Random();

double curr = 10.0;
for (int i = 0; i < 1000; i++) {
TestDataItem item = new TestDataItem();
item.setLabel(((Integer) i).toString());

curr += -2.0 + r.nextDouble() * 4.0;

item.setValue((int) Math.round(curr));
add(item);
}
}
}


public class TestDataItem {

private int _value;

public int getValue() {
return _value;
}

public int setValue(int value) {
_value = value;
return value;
}

private String _label;

public String getLabel() {
return _label;
}

public String setLabel(String value) {
_label = value;
return value;
}
}


DataGridView dataGrid = new DataGridView(this);

TestData data = new TestData();

dataGrid.setDataSource(data);

RelativeLayout layout = (RelativeLayout)findViewById(R.id.RelLayout1);

layout.addView(dataGrid);


and this is the error:
/AndroidRuntime: FATAL EXCEPTION: main
Process: smartview.oceanwide.com.androidsmartview, PID: 21714
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at android.icu.text.DecimalFormat.appendAffix(DecimalFormat.java:4317)
at android.icu.text.DecimalFormat.subformat(DecimalFormat.java:1395)
at android.icu.text.DecimalFormat.subformat(DecimalFormat.java:1331)
at android.icu.text.DecimalFormat.format(DecimalFormat.java:928)
at android.icu.text.DecimalFormat.format(DecimalFormat.java:784)
at java.text.DecimalFormat.format(DecimalFormat.java:617)
at java.text.NumberFormat.format(NumberFormat.java:289)
at com.infragistics.controls.NumericCellPresenter.formatCellValue(NumericCellPresenter.java:53)
at com.infragistics.controls.NumericCellPresenter.modelUpdatedOverride(NumericCellPresenter.java:26)
at com.infragistics.controls.CellPresenterBase.modelUpdated(CellPresenterBase.java:13)
at com.infragistics.controls.GridContentLayout.doRefresh(GridContentLayout.java:253)
at com.infragistics.controls.GridContentLayout.scheduleRefresh(GridContentLayout.java:65)
at com.infragistics.controls.GridContentLayout.refresh(GridContentLayout.java:27)
at com.infragistics.controls.GridImplementation.refreshPosition(GridImplementation.java:1493)
at com.infragistics.controls.GridImplementation.setViewport(GridImplementation.java:1734)
at com.infragistics.controls.DataGridView.onSizeChanged(DataGridView.java:196)
at android.view.View.sizeChange(View.java:19719)
at android.view.View.setFrame(View.java:19680)
at android.view.View.layout(View.java:19583)
at android.view.ViewGroup.layout(ViewGroup.java:6053)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
at android.view.View.layout(View.java:19586)
at android.view.ViewGroup.layout(ViewGroup.java:6053)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19586)
at android.view.ViewGroup.layout(ViewGroup.java:6053)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19586)
at android.view.ViewGroup.layout(ViewGroup.java:6053)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:758)
at android.view.View.layout(View.java:19586)
at android.view.ViewGroup.layout(ViewGroup.java:6053)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2484)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2200)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Parents Reply Children