Cannot bind List<T> data to listview in android - android-listview

I try to show custom list data to simple listview but listview does not show correctly list data value.
This is source ...
final Dialog dialog = new Dialog(context, R.style.cust_dialog);
dialog.setContentView(R.layout.orgcode);
dialog.setTitle("Product List...");
Button btnchkOk = (Button) dialog
.findViewById(R.id.btnOrgCodeOk);
Button btnchkCancel = (Button) dialog
.findViewById(R.id.btnOrgCodeCancel);
ListView lvlOrgCode = (ListView) dialog
.findViewById(R.id.lvlOrgCode);
// prevent touch outer side
dialog.setCanceledOnTouchOutside(false);
List<Object> orglist = new ArrayList();
List<OrgcodeInfo> orgcodeList = new ArrayList<OrgcodeInfo>();
orgcodeList = _CashSaleLoginLogic
.OrgCodeList("Select ORG_CODE as [Org Code] , ORG_NAME From VW_MainLogin Where USER_ID = '"
+ UserInfo.Role.toLowerCase() + "'");
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, orgcodeList) {
};
This is incorrect data
How can I fix it?

you need to set arrayAdapter to listView . Hear your listView object is lvlOrgCode
and your created adapter is
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, orgcodeList)
now add this line in your program :
lvlOrgCode.setAdapter(adapter);
i think it would help you.

Related

Auto Selection on Eclipse Widget Combo option

I would like to select widget combo first option by default which is in read only mode.Any suggestion
The select method of Combo sets the selected item.
Combo combo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
combo.setItems(... items array ....);
// Select first item
combo.select(0);
Note that this does not generate a selection changed event. To do that you need to use the notifyListeners call:
Event event = new Event();
event.widget = combo;
event.display = combo.getDisplay();
event.type = SWT.Selection;
combo.notifyListeners(SWT.Selection, event);

ToggleGroup in a GXT ColumnConfig

I'm using a ColumnConfig for presenting and editing data. For the gender I wann to have RadioButtons which where defined by an enumeration.
In every row i want to have:
id | (x) male ( ) female | name | date
The only way I have found was adding a "button" with defined rendering code. But there I cannot get the values or actions for pushed radio.
ColumnConfig<SomeValueGto, String> begIdCol = createColumnConfig(begIdProvider, "Id", sizeBegId);
//gender
ColumnConfig<SomeValueGto, GenderCode> genderCol = createColumnConfig(GRID_PROPERTIES.sex(), "Sex*", sizeGender);
ColumnConfig<SomeValueGto, String> nameCol = createColumnConfig(GRID_PROPERTIES.name(), "Name*", sizeName);
ColumnConfig<SomeValueGto, Date> birthdateCol = createColumnConfig(GRID_PROPERTIES.birthdate(), "Birthdate*", sizeBirthdate);
DateCell gebCell = new DateCell(DateTimeFormat.getFormat("dd.MM.yyyy"));
geburtsdatumCol.setCell(gebCell);
//add fields to the row
List<ColumnConfig<SomeValueGto, ?>> columnList = new ArrayList<ColumnConfig<SomeValueGto, ?>>();
columnList.add(begIdCol);
columnList.add(genderCol);
columnList.add(nameCol);
columnList.add(birthdateCol);
ColumnModel<SomeValueGto> cm = new ColumnModel<SomeValueGto>(columnList);
ListStore<SomeValueGto> gridStore = new ListStore<SomeValueGto>(GRID_PROPERTIES.id());
myGrid = new SLGrid<SomeValueGto>(gridStore, cm);
// empty entries. default ids 1/2/3
myGrid.getStore().add(new SomeValueGto(1));
myGrid.getStore().add(new SomeValueGto(2));
myGrid.getStore().add(new SomeValueGto(3));
final GridInlineEditing<SomeValueGto> editing = new GridInlineEditing<SomeValueGto>(myGrid);
editing.setErrorSummary(false);
editing.addEditor(nameCol, new TextField());
final SLDateField dateField = new SLDateField("date", false, true);
editing.addEditor(geburtsdatumCol, new Converter<Date, Date>() {.....}, dateField);
The helper createColumnConfig:
private <T> ColumnConfig<SomeValueGto, T> createColumnConfig(ValueProvider<SomeValueGto, T> aValueProvider, String aHeader, int aWidth) {
ColumnConfig<SomeValueGto, T> columnCol = new ColumnConfig<SomeValueGto, T>(aValueProvider);
columnCol.setHeader(aHeader);
columnCol.setWidth(aWidth);
columnCol.setMenuDisabled(true);
return columnCol;
}
Does anyone have already solved a problem like this?
GXT Grids uses com.google.gwt.cell.client.Cell to render data in the grid. I don't think the kind of cell you want exist in GXT. So I think you will have to implement your own cell. You can take example of ColorPaletteCell, which allow the user to select a color from the cell itself.
So you will need to implement the render and onBrowserEvent methods to manage your radio buttons and what append when the user click on it.

How to add MouseOver handler to a VectorFeature in GWT-Openlayers

I want to show a custom tooltip (popup) when user hovers over a Vector Feature on the GWT-openlayers map. I know that SelectFeature.setHover() will allow me to do this but that will also select the feature which i dont want to have.
it is like, when the user hovers, tooltip must be shown and when he clicks on the feature, then selection muse happen.
how can this be achieved?
Regards
Jatin
Check out this code.
This will also be added to our showcase but we have a little problem with the server at the moment. Will give a shout here when it is uploaded.
Note that the order in which you add the SelectFeature controls is important.
public void buildPanel() {
// create some MapOptions
MapOptions defaultMapOptions = new MapOptions();
defaultMapOptions.setNumZoomLevels(16);
// Create a MapWidget
final MapWidget mapWidget = new MapWidget("500px", "500px",
defaultMapOptions);
// Create an EmptyLayer as base layer
EmptyLayer.Options emptyLayerOptions = new EmptyLayer.Options();
emptyLayerOptions.setAttribution("EmptyLayer (c) GWT-Openlayers");
emptyLayerOptions.setIsBaseLayer(true); // make it a baselayer.
EmptyLayer emptyLayer = new EmptyLayer("Empty layer", emptyLayerOptions);
mapWidget.getMap().addLayer(emptyLayer);
// Add a clickable vectors to the map
// create a layer to add the vectors to
final Vector vectorLayer = new Vector("Vectorlayer");
mapWidget.getMap().addLayer(vectorLayer);
// SelectFeature control to capture clicks on the vectors
final SelectFeature selectFeature = new SelectFeature(vectorLayer);
selectFeature.setAutoActivate(true);
// SelectFeature control to capture hover on the vectors
SelectFeatureOptions selectFeatureHoverOptions = new SelectFeatureOptions();
// use the tempory style to be defined in the StyleMap
selectFeatureHoverOptions.setRenderIntent(RenderIntent.TEMPORARY);
selectFeatureHoverOptions.setHighlightOnly(true);
selectFeatureHoverOptions.setHover();
SelectFeature selectHoverFeature = new SelectFeature(vectorLayer,
selectFeatureHoverOptions);
selectHoverFeature.setClickOut(false);
selectHoverFeature.setAutoActivate(true);
mapWidget.getMap().addControl(selectHoverFeature);
mapWidget.getMap().addControl(selectFeature);
// Define a style for the vectors
Style style = new Style();
style.setFillColor("red");
style.setStrokeColor("green");
style.setStrokeWidth(2);
style.setFillOpacity(0.9);
style.setPointRadius(30);
Style selectedStyle = new Style();
selectedStyle.setFillColor("yellow");
selectedStyle.setStrokeColor("yellow");
selectedStyle.setStrokeWidth(2);
selectedStyle.setFillOpacity(0.9);
selectedStyle.setPointRadius(30);
Style hoverStyle = new Style();
hoverStyle.setFillColor("blue");
hoverStyle.setStrokeColor("pink");
hoverStyle.setStrokeWidth(2);
hoverStyle.setFillOpacity(0.9);
hoverStyle.setPointRadius(30);
StyleMap styleMap = new StyleMap(style, selectedStyle, hoverStyle);
vectorLayer.setStyleMap(styleMap);
// Add a point
Point point = new Point(146.7, -41.8);
final VectorFeature pointFeature = new VectorFeature(point);
vectorLayer.addFeature(pointFeature);
// capture clicks on the vectorlayer
vectorLayer
.addVectorFeatureSelectedListener(new VectorFeatureSelectedListener() {
public void onFeatureSelected(
FeatureSelectedEvent eventObject) {
Window.alert("The vector is now selected.\nIt will get de-selected when closing this popup.");
selectFeature.unSelect(eventObject.getVectorFeature());
}
});
// Attach a popup to the point, we use null as size cause we set
// autoSize to true
// Note that we use FramedCloud... This extends a normal popup and
// creates is styled as a baloon
// We want to display this popup on hover, and hide it when hovering
// ends
final Popup popup = new FramedCloud("id1",
pointFeature.getCenterLonLat(), null,
"<h1>Some popup text</H1><BR/>And more text", null, false);
popup.setPanMapIfOutOfView(true); // this set the popup in a strategic
// way, and pans the map if needed.
popup.setAutoSize(true);
pointFeature.setPopup(popup);
// capture hover by adding a listener to the control, and display the
// popup
selectHoverFeature
.addFeatureHighlightedListener(new FeatureHighlightedListener() {
public void onFeatureHighlighted(VectorFeature vectorFeature) {
mapWidget.getMap().addPopup(vectorFeature.getPopup());
}
});
// capture unhover, and remove popup
selectHoverFeature
.addFeatureUnhighlightedListener(new FeatureUnhighlightedListener() {
public void onFeatureUnhighlighted(
VectorFeature vectorFeature) {
mapWidget.getMap()
.removePopup(vectorFeature.getPopup());
}
});
// Center and zoom to a location
mapWidget.getMap().setCenter(new LonLat(146.7, -41.8), 6);
contentPanel
.add(new HTML(
"<p>This example shows how to add a Vector (point) to map, and do some action when hovering, and another when clicking.</p>"
+ "<p>"
+ "<LI>Hover over the point. This will cause a popup to show, and change the style of the point to the temporary style.</LI>"
+ "<LI>Then when you click the Vector gets selected, gets another style, and a Window.alert is displayed.</LI>"
+ "<LI>When closing the Window.alert, the Vector gets de-selected.</p>"));
contentPanel.add(mapWidget);
initWidget(contentPanel);
mapWidget.getElement().getFirstChildElement().getStyle().setZIndex(0);
}
You must indeed use a SelectFeature to achieve this.
The secret is that you must pass SelectFeatureOptions with highlight only enabled.
Something like
SelectFeatureOptions selectFeatureOptions = new SelectFeatureOptions();
selectFeatureOptions.setHighlightOnly(true);
SelectFeature selectFeature = new SelectFeature(vectorLayer,selectFeatureOptions);

GWT SimplePager

I'm trying to use SimplePager. But I do not understand why the last page next button is still active. If I click on the button it advances on existing records, instead of disabling the button.
My test code is as follows:
CellList <String> cellList = new CellList <String> (TextCell new ());
ListDataProvider <String> dataProvider = new ListDataProvider <String> ();
List <String> dataProvider.getList data = ();
for (int i = 0; i <30; i + +) {
data.add ("Item" + i);
}
dataProvider.addDataDisplay (cellList);
SimplePager pager = new SimplePager (SimplePager.TextLocation.CENTER, GWT. <SimplePager.Resources> Created (SimplePager.Resources.class), false, -1, true);
pager.setDisplay (cellList);
pager.setPageSize (20);
pager.setRangeLimited (false);
/ / Add the list to the page and pager.
VerticalPanel vPanel VerticalPanel = new ();
vPanel.add (pager);
vPanel.add (cellList);
RootPanel.get (). Add (vPanel);
Thanks a lot
try adding the number of rows that your cell list has:
cellList.setRowCount(dataProvider.size(), true);
In this case you are populating the data from a list, so you know exactly how many rows you will have and that's why the second parameter is set to true. If you are populating the celllist from a async call is it better to set it to false.
I hope it helps!

why click event is not happening on table row?

Programmatically I am creating tablelayout and also adding rows to it. But when I clicked on table row its not getting clicked.
In every row I am adding textview and Imageview.I have set onclickListener to tablelayout.
TextView txt = (TextView) row.getChildAt(0);
String stTitle = txt.getText().toString();
int index = strTitle.indexOf(stTitle);
Log.d("AllFeat", " index "+index);
Log.d("AllFeat", " title "+stTitle);
int id = nId.get(index);
Intent i = new Intent(CatalogPage.this,AllFeats.class);
i.putExtra("id", id);
i.putExtra("title",stTitle);
startActivity(i);
The above code I am writing in tablelayout.setOnclickListener.
First you can set rowId using setId(nt).After calling setcontentview(view) .findViewById and setOnclickListener();