Android's ListView doesn't show content after changing orientation - android-listview

I use a content provider to display data from a database. The content is shown in a ListActivity. When I change the orientation of the phone, sometimes it won't reload the data and shows an empty ListView. What could be the reason? It happens about every 4-5th time...
There's an actionbar spinner that has three items: Show All, Show Date, Show Location which will query the db to only show a subset
public class MainActivity extends ListActivity {
private Cursor mCursor = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mSimpleCursorAdapter = new SpecialAdapter(this,
R.layout.row,
null,
PROJECTION,
new int[] { R.id.titleID, R.id.dateTimeOrLocationID1 , R.id.dateTimeOrLocationID2 },
CursorAdapter.NO_SELECTION);
//mListView = (ListView) findViewById(android.R.id.list);
//mListView.setAdapter(mSimpleCursorAdapter);
setListAdapter(mSimpleCursorAdapter);
mOnNavigationListener = new OnNavigationListener() {
#Override
public boolean onNavigationItemSelected(int position, long itemId) {
switch(position) {
case 0:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, null, null, null);
break;
case 1:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, " Date NOT NULL", null, null);
break;
case 2:
mCursor = getContentResolver().query(ReminderContentProvider.CONTENT_URI, PROJECTION, " Address NOT NULL", null, null);
break;
default:
break;
}
getLoaderManager().restartLoader(0, null, MainActivity.this);
return true;
}
};
}
#Override
public void onResume() {
super.onResume();
getLoaderManager().restartLoader(0, null, this);
}
#Override
public void onStart() {
int showWhat = prefs.getInt(Utils.PREF_SHOW_ALL_DATE_OR_ADDRESS, 1);
VisibilitySelection enumValue = VisibilitySelection.values()[showWhat-1];
switch (enumValue) {
case SHOW_ALL:
mShowProperty = VisibilitySelection.SHOW_ALL;
break;
case SHOW_DATE_TIME:
mShowProperty = VisibilitySelection.SHOW_DATE_TIME;
break;
case SHOW_ADDRESS:
mShowProperty = VisibilitySelection.SHOW_ADDRESS;
break;
default:
mShowProperty = VisibilitySelection.SHOW_ALL;
break;
}
getLoaderManager().restartLoader(0, null, this);
}
#Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
CursorLoader loader = null;
switch(mShowProperty) {
case SHOW_ALL:
loader = new CursorLoader(this, ReminderContentProvider.CONTENT_URI, PROJECTION, null, null, null);
break;
case SHOW_DATE_TIME:
loader = new CursorLoader(this, ReminderContentProvider.CONTENT_URI, PROJECTION, " Date NOT NULL", null, null);
break;
case SHOW_ADDRESS:
loader = new CursorLoader(this, ReminderContentProvider.CONTENT_URI, PROJECTION, " Address NOT NULL", null, null);
break;
}
return loader;
}
#Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mSimpleCursorAdapter.swapCursor(data);
}
#Override
public void onLoaderReset(Loader<Cursor> loader) {
mSimpleCursorAdapter.swapCursor(null);
}
}

Related

org.eclipse.core.runtime.AssertionFailedException: assertion failed:

I am trying to create a table with ComboBoxCellEditor column. When I set value that time below exception is coming.
import org.eclipse.jface.util.Policy;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/............/
public class Test {
public static void main(String[] args) {
Shell shell = new Shell();
shell.setText("TableViewer Example");
GridLayout layout = new GridLayout();
shell.setLayout(layout);
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
composite.setLayout(new GridLayout(1, false));
Table testTable = new Table(composite, SWT.BORDER);
testTable.setLinesVisible(true);
testTable.setHeaderVisible(true);
GridData tableData = new GridData(SWT.FILL, SWT.FILL, true, false);
tableData.heightHint = 300;
testTable.setLayoutData(tableData);
TableViewerColumn columnViewer = null;
String[] columnNames = { "Name", "Laptops" };
TableViewer testTableViewer = new TableViewer(testTable);
for (int i = 0; i < columnNames.length; i++) {
columnViewer = new TableViewerColumn(testTableViewer, SWT.LEFT);
columnViewer.getColumn().setText(columnNames[i]);
if (columnNames[i].equals("Name")) {
columnViewer.getColumn().setWidth(200);
} else if (columnNames[i].equals("Laptops")) {
columnViewer.getColumn().setWidth(300);
}
columnViewer.getColumn().setResizable(true);
columnViewer.getColumn().setMoveable(true);
columnViewer.setLabelProvider(new TestColumnLabelProvider(i));
}
testTableViewer.setContentProvider(new TestContentProvider());
testTableViewer.setColumnProperties(columnNames);
TestBean[] testBeans = new TestBean[5];
for (int i = 0; i < 5; i++) {
TestBean bean = new TestBean();
TableViewerColumn[] getTableViewerColumns =
getTableViewerColumns(testTableViewer);
for (int j = 0; j < getTableViewerColumns.length; j++) {
getTableViewerColumns[j].setEditingSupport(new
TestEditingSuport(testTableViewer, j, bean.getListOfLaptop));
}
bean.setName("Debasish" + i);
bean.setLaptop(bean.getListOfLaptop[i]);
testBeans[i] = bean;
}
testTableViewer.setInput(testBeans);
shell.open();
Display display = shell.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
public static TableViewerColumn[] getTableViewerColumns(TableViewer
tableViewer) {
TableColumn[] columns = tableViewer.getTable().getColumns();
TableViewerColumn[] viewerColumns = new TableViewerColumn[columns.length];
for (int i = 0; i < columns.length; i++) {
TableColumn tableColumn = columns[i];
viewerColumns[i] = (TableViewerColumn) tableColumn.getData(Policy.JFACE +
".columnViewer");
}
return viewerColumns;
}
}
/............./
class TestBean {
private String name;
private String laptop;
public String[] getListOfLaptop = { "Acer", "HP", "Lenovo", "Dell", "Benq"
};
//getter and setter method
}
/..................../
class TestEditingSuport extends EditingSupport {
private int m_column;
private CellEditor m_editor;
public TestEditingSuport(ColumnViewer viewer, int column,
String[] listOfTestBean) {
super(viewer);
m_column = column;
// Create the correct editor based on the column index
switch (column) {
case 0:
case 1:
m_editor = new ComboBoxCellEditor(
((TableViewer) viewer).getTable(), listOfTestBean);
break;
default:
}
}
#Override
protected CellEditor getCellEditor(Object element) {
return m_editor;
}
#Override
protected boolean canEdit(Object element) {
return true;
}
#Override
protected Object getValue(Object element) {
TestBean bean = (TestBean) element;
Object value = null;
switch (m_column) {
case 0:
value = bean.getName();
break;
case 1:
value = bean.getLaptop();
break;
default:
}
return value;
}
#Override
protected void setValue(Object element, Object value) {
TestBean bean = (TestBean) element;
switch (m_column) {
case 0:
if (valueChanged(bean.getName(), (String) value)) {
bean.setName((String) value);
}
getViewer().update(bean, null);
break;
case 1:
int index = (Integer) value;
String laptop = bean.getListOfLaptop[index];
if (valueChanged(bean.getLaptop(), laptop)) {
bean.setLaptop(laptop);
}
getViewer().update(bean, null);
break;
default:
}
}
private boolean valueChanged(String previousValue, String currentValue) {
boolean changed = false;
if ((previousValue == null) && (currentValue != null)) {
changed = true;
} else if ((previousValue != null) && (currentValue != null) && (!previousValue.equals(currentValue))) {
changed = true;
}
return changed;
}
}
/............../
class TestContentProvider implements IStructuredContentProvider {
#Override
public Object[] getElements(Object inputElement) {
return (Object[]) inputElement;
}
}
/........................./
class TestColumnLabelProvider extends ColumnLabelProvider {
private int m_column;
public TestColumnLabelProvider(int column) {
this.m_column = column;
}
public String getText(Object element) {
String text = null;
if (element instanceof TestBean) {
TestBean testBean = (TestBean) element;
switch (m_column) {
case 0:
text = testBean.getName();
break;
case 1:
text = testBean.getLaptop();
break;
default:
}
}
return text;
}
}
/....................../
ComboCellEditor values are integer indexes in to the list of values you give it in the constructor.
Your getValue method of your EditingSupport class must return an Integer index in to the values list.
The setValue method of your EditingSupport class will be given an Integer containing the selected index.

AutoCompleteTextField list does not always scroll to top?

The AutoCompleteTextField seems to work exactly as intended until I start backspacing in the TextField. I am not sure what the difference is, but if I type in something like "123 M" then I get values that start with "123 M". If I backspace and delete the M leaving "123 " in the field, the list changes, but it does not scroll to the top of the list.
I should note that everything works fine on the simulator and that I am experiencing this behavior when running a debug build on my iPhone.
EDIT: So this does not only seem to happen when backspacing. This image shows the results I have when typing in an address key by key. In any of the pictures where the list isn't viewable or is clipped, I am able to drag down on the list to get it to then display properly. I have not tried this on an Android device.
EDIT2:
public class CodenameOneTest {
private Form current;
private Resources theme;
private WaitingClass w;
private String[] properties = {"1 MAIN STREET", "123 E MAIN STREET", "12 EASTER ROAD", "24 MAIN STREET"};
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
}
public void start() {
if(current != null) {
current.show();
return;
}
Form form = new Form("AutoCompleteTextField");
form.setLayout(new BorderLayout());
final DefaultListModel<String> options = new DefaultListModel<>();
AutoCompleteTextField ac = new AutoCompleteTextField(options) {
protected boolean filter(String text) {
if(text.length() == 0) {
options.removeAll();
return false;
}
String[] l = searchLocations(text);
if(l == null || l.length == 0) {
return false;
}
options.removeAll();
for(String s : l) {
options.addItem(s);
}
return true;
};
};
Container container = new Container(BoxLayout.y());
container.setScrollableY(true); // If you comment this out then the field works fine
container.add(ac);
form.addComponent(BorderLayout.CENTER, container);
form.show();
}
String[] searchLocations(String text) {
try {
if(text.length() > 0) {
if(w != null) {
w.actionPerformed(null);
}
w = new WaitingClass();
String[] properties = getProperties(text);
if(Display.getInstance().isEdt()) {
Display.getInstance().invokeAndBlock(w);
}
else {
w.run();
}
return properties;
}
}
catch(Exception e) {
Log.e(e);
}
return null;
}
private String[] getProperties(String text) {
List<String> returnList = new ArrayList<>();
List<String> propertyList = Arrays.asList(properties);
for(String property : propertyList) {
if(property.startsWith(text)) {
returnList.add(property);
}
}
w.actionPerformed(null);
return returnList.toArray(new String[returnList.size()]);
}
class WaitingClass implements Runnable, ActionListener<ActionEvent> {
private boolean finishedWaiting;
public void run() {
while(!finishedWaiting) {
try {
Thread.sleep(30);
}
catch(InterruptedException ex) {
ex.printStackTrace();
}
}
}
public void actionPerformed(ActionEvent e) {
finishedWaiting = true;
return;
}
}
public void stop() {
current = Display.getInstance().getCurrent();
if(current instanceof Dialog) {
((Dialog)current).dispose();
current = Display.getInstance().getCurrent();
}
}
public void destroy() {
}
}
I used this code on an iPhone 4s:
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Form("AutoComplete", new BorderLayout());
if(apiKey == null) {
hi.add(new SpanLabel("This demo requires a valid google API key to be set in the constant apiKey, "
+ "you can get this key for the webservice (not the native key) by following the instructions here: "
+ "https://developers.google.com/places/web-service/get-api-key"));
hi.getToolbar().addCommandToRightBar("Get Key", null, e -> Display.getInstance().execute("https://developers.google.com/places/web-service/get-api-key"));
hi.show();
return;
}
Container box = new Container(new BoxLayout(BoxLayout.Y_AXIS));
box.setScrollableY(true);
for(int iter = 0 ; iter < 30 ; iter++) {
box.add(createAutoComplete());
}
hi.add(BorderLayout.CENTER, box);
hi.show();
}
private AutoCompleteTextField createAutoComplete() {
final DefaultListModel<String> options = new DefaultListModel<>();
AutoCompleteTextField ac = new AutoCompleteTextField(options) {
#Override
protected boolean filter(String text) {
if(text.length() == 0) {
return false;
}
String[] l = searchLocations(text);
if(l == null || l.length == 0) {
return false;
}
options.removeAll();
for(String s : l) {
options.addItem(s);
}
return true;
}
};
ac.setMinimumElementsShownInPopup(5);
return ac;
}
String[] searchLocations(String text) {
try {
if(text.length() > 0) {
ConnectionRequest r = new ConnectionRequest();
r.setPost(false);
r.setUrl("https://maps.googleapis.com/maps/api/place/autocomplete/json");
r.addArgument("key", apiKey);
r.addArgument("input", text);
NetworkManager.getInstance().addToQueueAndWait(r);
Map<String,Object> result = new JSONParser().parseJSON(new InputStreamReader(new ByteArrayInputStream(r.getResponseData()), "UTF-8"));
String[] res = Result.fromContent(result).getAsStringArray("//description");
return res;
}
} catch(Exception err) {
Log.e(err);
}
return null;
}
I was able to create this issue but not the issue you describe.

How to upload an Image to Facebook album using Facebook sdk 4 Android Studio

Hi everyone I have a question.Please help me so first of all here is my code :
Uri chosenImageUri = data.getData();
final String imagepath = getpath(chosenImageUri);
final Bitmap bm = BitmapFactory.decodeFile(imagepath);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(),
getIntent().getStringExtra("albumid") + "/photos",
null,
HttpMethod.POST,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
}
});
Bundle parametre = new Bundle();
parametre.putByteArray("source", byteArray);
request.setParameters(parametre);
request.executeAsync();
I wanna post an image to Facebook album who I am get the picture and set into GridView. I don't know what can I do anymore. I spend 1.5 days for this upload process. I need help.
I have this error :
{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[user_likes, user_posts, user_friends, user_photos, user_location, public_profile, user_birthday]}
Hi everyone I found the solution.This is for when you want upload to album which you are pick. So I wanna explain:
First of all you make this:
private CallbackManager callbackManager;
LoginManager manager;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gridview);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
....
}
Then choose from Gallery or Camera an upload it.
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_grid, menu);
return super.onCreateOptionsMenu(menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.action_upload:
chooseImageDialog("", this, false);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void chooseImageDialog(final String title,
final Context context, final boolean redirectToPreviousScreen) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
alertDialog.setTitle(title);
alertDialog.setPositiveButton("Gallery \n",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(intent, RQ_GALLERY);
}
});
alertDialog.setNegativeButton("Camera",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intentfile = new Intent(
"android.media.action.IMAGE_CAPTURE");
startActivityForResult(intentfile, RQ_CAMERA);
dialog.dismiss();
}
});
alertDialog.show();
}
#Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RQ_GALLERY:
List<String> permissionNeeds = Arrays.asList("publish_actions");
manager = LoginManager.getInstance();
manager.logInWithPublishPermissions(this, permissionNeeds);
manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Upload(data);
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException exception) {
}
});
break;
case RQ_CAMERA:
if (resultCode == RESULT_OK) {
List<String> permissions = Arrays.asList("publish_actions");
manager = LoginManager.getInstance();
manager.logInWithPublishPermissions(this, permissions);
manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Upload(data);
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException exception) {
}
});
} else {
/* Toast.makeText(activityname.this, "Unable to get Image",
Toast.LENGTH_SHORT).show();*/
}
break;
}
}
private void Upload(Intent data) {
if(data != null){
AccessToken accessToken = AccessToken.getCurrentAccessToken();
GraphRequest request = GraphRequest.newPostRequest(accessToken, getIntent().getStringExtra("albumid") + "/photos", null,
new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse graphResponse) {
}
});
Bundle params = request.getParameters();
Uri chosenImageUri = data.getData();
final String imagepath = GetPath(chosenImageUri);
final Bitmap bm = BitmapFactory.decodeFile(imagepath);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
params.putByteArray("source", byteArray);
request.setParameters(params);
request.executeAsync();
}else {
Toast.makeText(getApplicationContext(),"No Image was selected",Toast.LENGTH_LONG).show();
}
}
private String GetPath(Uri chosenImageUri) {
String res = null;
String[] proj = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(chosenImageUri, proj, null, null, null);
if (cursor.moveToFirst()) {
;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
res = cursor.getString(column_index);
}
cursor.close();
return res;
}
If you can improve this solution ,please post it.Thank you .

How can i start an Activity from my sherlock ActionBar Item?

how can I start any activity from my sherlock ActionBar Item Navigation Menu?
This is my code (i've tried with toast for now and function).
public class MainActivity extends SherlockActivity implements OnNavigationListener {
private String[] pasti;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
pasti = getResources().getStringArray(R.array.Pasti);
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.Pasti, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setSubtitle("The Subtitle");
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayShowCustomEnabled(false);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
#Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
Toast toast=Toast.makeText(this,"Selected: " + pasti[itemPosition],Toast.LENGTH_LONG);
toast.show();
return true;
}
}
`
please help. thanks
I've solved with this code:
switch (itemPosition) {
case 1:
Intent primi = new Intent();
primi.setClass(getApplicationContext(), PrimiPiatti.class);
startActivity(primi);
break;
case 2:
break;
case 3:
break;
}
// return super.onOptionsItemSelected(itemPosition);
return true;
}
};
getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
}
#Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
// TODO Auto-generated method stub
return false;
}

how to get data from database with parameter

I'm trying to show a list with the list items from my database having 2 parameters, but the list didn't show.
Here's my query database from php:
$query = mysql_query("SELECT d.model_name from detail_product d join brand b on d.id_brandtype = b.id_brand join biketype t on d.id_biketype = t.id_type where d.id_brandtype = 1 and d.id_biketype=1");
I've set the parameter there.
and here's my DAO:
public class info_xc_dao {
public final static int VIEW_POL_XC = 0;
private static final String URL_VIEW_POL_XC = ServerConfiguration.SERVER_URL
+ "polygon_xc.php";
private int Action;
pol_xc_Result pol_xc_Result;
public info_xc_dao(pol_xc_Result pol_xc_Result) {
// TODO Auto-generated constructor stub
this.pol_xc_Result = pol_xc_Result;
}
public void view_pol_xc() {
Action = VIEW_POL_XC;
new ConnectionHandler(connectionResult, null, URL_VIEW_POL_XC,
ConnectionHandler.GET);
}
public ConnectionResult connectionResult = new ConnectionResult() {
#Override
public void gotResult(String result, String message) {
// TODO Auto-generated method stub
if (result != null) {
switch (Action) {
case VIEW_POL_XC:
try {
JSONObject jsonObject = null;
jsonObject = new JSONObject(result);
int response = jsonObject.getInt("result");
if (response != 0) {
JSONArray jsonArray = new JSONArray(
jsonObject.getString("data"));
ArrayList<Entity_Detail_Product> arrayList = new ArrayList<Entity_Detail_Product>();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject pol_xc = new JSONObject(jsonArray
.get(i).toString());
Entity_Detail_Product ent_detail_product = new Entity_Detail_Product();
ent_detail_product.setModel_name(pol_xc
.getString("model_name"));
arrayList.add(ent_detail_product);
}
pol_xc_Result.gotResult(arrayList, null, Action);
} else {
String error_message = jsonObject
.getString("message");
pol_xc_Result.gotResult(null, error_message,
Action);
}
} catch (JSONException e) {
// TODO: handle exception
pol_xc_Result.gotResult(null,
"Failed parsing data from database. Please try again.. "
+ e.getMessage(), Action);
Log.e("CON ERROR", e.getMessage());
}
}
} else {
pol_xc_Result.gotResult(null, message, Action);
Log.e("CON ERROR", message);
}
}
};
public static abstract class pol_xc_Result {
public abstract void gotResult(Object obj, String message, int action);
}
and here's my activity to call DAO.
public class Information_XC_Activity extends ListActivity {
WebView mWebView;
TextView tv;
private Adapter_DetailPolXC adapterDetailPolXC;
private ListView mainListView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.info_xc);
final ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setTitle(getString(R.string.app_name));
int index = getIntent().getIntExtra("text", 0);
mWebView = (WebView) findViewById(R.id.webview_xc);
String temp = "<html><body>" + "<p align=\"justify\">"
+ getString(R.string.xc_info + index) + "</p> "
+ "</body></html>";
mWebView.loadData(temp, "text/html", "utf-8");
ArrayList<Entity_Detail_Product> arraylist = new ArrayList<Entity_Detail_Product>();
adapterDetailPolXC = new Adapter_DetailPolXC(this, R.layout.info_row,
arraylist);
setListAdapter(adapterDetailPolXC);
new info_xc_dao(response).view_pol_xc();
}
pol_xc_Result response = new pol_xc_Result() {
#Override
public void gotResult(Object obj, String message, int action) {
// TODO Auto-generated method stub
// actionBar.setProgressBarVisibility(View.INVISIBLE);
#SuppressWarnings("unchecked")
ArrayList<Entity_Detail_Product> arrayList = (ArrayList<Entity_Detail_Product>) obj;
AlertDialog.Builder builder = new AlertDialog.Builder(
Information_XC_Activity.this);
if (arrayList == null) {
builder.setIcon(R.drawable.alert_warning);
builder.setTitle("Error");
builder.setMessage("Data Not Found !");
builder.setNegativeButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
for (Entity_Detail_Product entity_Detail_Product : arrayList) {
adapterDetailPolXC.add(entity_Detail_Product);
}
adapterDetailPolXC.notifyDataSetChanged();
}
}
};
private class Adapter_DetailPolXC extends
ArrayAdapter<Entity_Detail_Product> {
private ArrayList<Entity_Detail_Product> items;
public Adapter_DetailPolXC(Context context, int textViewResourceId,
ArrayList<Entity_Detail_Product> items) {
super(context, textViewResourceId, items);
this.items = items;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View v = convertView;
if (v == null) {
LayoutInflater layoutInflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = (View) layoutInflater.inflate(R.layout.info_xc, null);
}
Entity_Detail_Product adapter_Detail_Product = items.get(position);
if (adapter_Detail_Product != null) {
TextView textView = (TextView) v.findViewById(R.id.tv_test);
if (textView != null)
textView.setText(adapter_Detail_Product.getModel_name());
}
return v;
}
}
and here's my logcat :
09-22 12:41:30.239: W/IInputConnectionWrapper(12808): showStatusIcon on inactive InputConnection
09-22 12:41:33.129: E/HttpResponse(12808): {"result":1,"data":[{"0":"1","id_brand":"1","1":"Polygon","brand_name":"Polygon"},{"0":"2","id_brand":"2","1":"United Bike","brand_name":"United Bike"},{"0":"3","id_brand":"3","1":"WimCycle","brand_name":"WimCycle"}]}
09-22 12:41:35.009: E/HttpResponse(12808): {"result":1,"data":[{"0":"1","id_type":"1","1":"Cross Country (XC)","type_name":"Cross Country (XC)"},{"0":"2","id_type":"2","1":"Bicycle Motocross (BMX)","type_name":"Bicycle Motocross (BMX)"},{"0":"3","id_type":"3","1":"Free Ride (FR)","type_name":"Free Ride (FR)"},{"0":"4","id_type":"4","1":"DownHill (DH)","type_name":"DownHill (DH)"},{"0":"5","id_type":"5","1":"DirtJump (DJ)","type_name":"DirtJump (DJ)"},{"0":"6","id_type":"6","1":"Road Bike (RB)","type_name":"Road Bike (RB)"}]}
09-22 12:41:37.219: D/PhoneWindow(12808): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView#405440f0 has no id.
09-22 12:41:37.519: I/webclipboard(12808): clipservice: android.sec.clipboard.ClipboardExManager#405d4d40
09-22 12:41:37.839: V/webview(12808): OnSizeChanged: Enter
09-22 12:41:37.859: E/HttpResponse(12808): {"result":1,"data":[{"0":"1","id_type":"1","1":"Cross Country (XC)","type_name":"Cross Country (XC)"},{"0":"2","id_type":"2","1":"Bicycle Motocross (BMX)","type_name":"Bicycle Motocross (BMX)"},{"0":"3","id_type":"3","1":"Free Ride (FR)","type_name":"Free Ride (FR)"},{"0":"4","id_type":"4","1":"DownHill (DH)","type_name":"DownHill (DH)"},{"0":"5","id_type":"5","1":"DirtJump (DJ)","type_name":"DirtJump (DJ)"},{"0":"6","id_type":"6","1":"Road Bike (RB)","type_name":"Road Bike (RB)"}]}
09-22 12:41:38.169: E/CON ERROR(12808): No value for model_name
09-22 12:41:38.859: V/webview(12808): ZoomScale 3 mPreserveZoom: false
09-22 12:41:38.889: D/CONTEXT(12808): m_mainFrame->editor()->hasComposition not
09-22 12:41:38.959: D/CONTEXT(12808): m_mainFrame->editor()->hasComposition not