I have a tableview in a View XML and it crashes when I set the data via setData on SK6. Works fine on SDK 5, but on SDK6 it crashes when I assign the same data twice which I do when I need to switch data sets. This is only on Android as iOS works as it should
$table.setData(myDataSet);
$table.data = [];
$table.setData(newDataSet); // This is ok
$table.data = [];
$table.setData(myDataSet); // Re-assigning myDataSet crashes the table view
I am guessing this is a bug in SDK6 forAndroid - anyone else had the same issue?
Thanks
Nigel
Related
Using Qt Designer, I created an Item class inheriting from QWidget, and added a few widgtes.
Then, again using Qt Designer, I created a MainWindow from QMainWindow, and added a QListWidget object called list, and a QPushButton called pushButton.
On MainWindow::MainWindow(QWidget *parent), I added to the default code:
ui->list->setSizeAdjustPolicy(QListWidget::AdjustToContents);
On void MainWindow::on_pushButton_clicked(), I wrote:
Item *my_item = new Item(this);
QListWidgetItem * item = new ListWidgetItem();
item->setSizeHint(QSize(0, 400));
ui->list->addItem(item);
ui->list->setItemWidget(item, my_item );
Testing on the Linux Ubuntu running on my notebook, it all goes well, but when I run on my Android Moto G4 cell phone, the Item objects inserted in list are never displayed correctly. Using 400 in setSizeHint makes the widgets to be displayed, but cut at the bottom. Using, say, 100, makes the widgets to be squeezed, impossible to read.
Does anyone have any idea on how to make it work?
Thanks!!
I am writing test cases to check the proper functioning of the Android Audio Recorder App.
In one such test case, I want my Python code to display the names of recordings in the terminal.
Eg:
Recording20.mp3
Recording19.mp3
...
...
Recording3.mp3
Recording2.mp3
Recording1.mp3
Recording0.mp3
All the TextView content has the same resource-id: text1
Below is the screenshot from UIAutomatorViewer
I am using Ubuntu 14.04.
I implemented scroll method :
i = 0
while i <= 2:
for num in range(0,5):
element1 = WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, '//android.widget.ListView/android.widget.TextView[#index= %d]' % num)))
self.assertIsNotNone(element1)
print element1.text
element_to_tap = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.TextView[#index= 5]')
element_to_drag_to = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.TextView[#index= 0]')
self.driver.scroll(element_to_tap, element_to_drag_to)
i = i +1
Here, I am trying to display 5 list elements each time, before scrolling.. I had 15 list elements right now.
Result I am getting now is :
Recording15.mp3
Recording14.mp3
Recording13.mp3
Recording12.mp3
Recording11.mp3
Recording6.mp3
Recording5.mp3
Recording4.mp3
Recording3.mp3
Recording2.mp3
Recording6.mp3
Recording5.mp3
Recording4.mp3
Recording3.mp3
Recording2.mp3
ok
Recordings in the middle are missing.. It scrolls completely to the bottom..
How can I find the total count of the android
ListView contents ? It would be helpful if I could get a way to count those, in order to put as a condition in loops. It gets terminated, when condition becomes false.
I searched a lot, but couldn't find.
I am too close to the answer, yet too far..
I am trying to list hundreds of items in a ListView using React-Native on Android platform. Version of react-native is 0.22. Here is my ListView component:
<ListView dataSource={dataSource}
onEndReached={onEndReached}
renderRow={this.renderRow.bind(this)}/>
When the page loads I retrieve batch of data and fullfill datasource as follows:
onEndReached(page) {
let {dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})} = this.state;
return myService.search({page})
.then(newRows => {
this.setState({
dataSource: dataSource.cloneWithRows(newRows),
page: page
});
});
}
renderRow(row){console.log(row.id); // This is printed for all rows regardless of whether it is displayed on the screen or not}
Basically what happens is, onEndReached function is triggered with a slight slide or sometimes even without any gestures. I thought this function will only be called when all the rows given to dataSource is rendered. Strangely I see that my renderRow function is called for all my rows, not just for the row displayed on the screen. I tried using scrollRenderAheadDistance but to no avail.
May anyone point me what am I doing wrong?
The problem was I had my ListView under a ScrollView it was breaking its behaviour. After removing the ListView outside ScrollView it started to work as expected.
I've implementing a widget with RemoteViewsService containing with a ListView of items where all the items are clickable to launch a service. In short I'm using setPendingIntentTemplate in my AppWidgetProvider.onUpdate() and setOnClickFillInIntent in my RemoteViewsService.RemoteViewsFactory().
And in most cases I get the expected behavior. However, when using up some memory and going back to try to click on an item in the list again sometimes nothing happens when clicking on items in a list: the service isn't launched, and no touch feedback is given. If I have several widgets one of the lists may have the problem while the others don't.
Does anyone know how to solve this problem?
Some other testing has revealed that:
If I scroll for a while in a list with the problem and then try to click again, it works! My first thought was that the reason was that RemoteViewsFactory.getView was called and so updated the pending intent, but checking the logs I can see that this method isn't entered.
I've also logged RemoteViewsService.RemoteViewsFactory.onDestroy to see if the reason for the problem was that this was removed, but this was not the case.
If I manage to call AppWidgetManager.updateAppWidget (so that AppWidgetProvider.onUpdate will run) the problem dissapears (I call updateAppWidget from inside my main app).
These three observations seems to point to the problem being in AppWidgetManager rather than RemoteViewsFactory.
AppWidgetProvider.onUpdate:
#Override
public void onUpdate(Context iContext, AppWidgetManager iWidgetMgr,
int[] iWidgetIds){
Log.d(DbgU.getAppTag(), DbgU.getMethodName());
//Going through all widgets placed (could be more than one)
for(int i = 0; i < iWidgetIds.length; i++){
//Setting up the remote view service
Intent tmpRVServiceIntent = new Intent(iContext,
RemoteViewsServiceC.class);
tmpRVServiceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
iWidgetIds[i]);
tmpRVServiceIntent.setData(Uri.parse(tmpRVServiceIntent.toUri(
Intent.URI_INTENT_SCHEME)));
//Setting up the remote views
RemoteViews tmpRemoteViews = new RemoteViews(iContext.getPackageName(),
R.layout.widget);
tmpRemoteViews.setRemoteAdapter(R.id.widget_listview,
tmpRVServiceIntent);
tmpRemoteViews.setEmptyView(R.id.widget_listview,
R.id.widget_empty_view);
//Setting up the pending intent template (the id will be filled
//in later in RemoteViewsFactoryC.getViewAt())
Intent tmpTemplateIntent = new Intent(iContext,
LauncherServiceC.class);
tmpTemplateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
iWidgetIds[i]);
PendingIntent tmpPendingIntent = PendingIntent.getService(iContext,
0, tmpTemplateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
tmpRemoteViews.setPendingIntentTemplate(R.id.widget_listview,
tmpPendingIntent);
//Applying the update for the views
iWidgetMgr.updateAppWidget(iWidgetIds[i], tmpRemoteViews);
}
}
RemoteViewsService.RemoteViewsFactory.getViewAt:
#Override
public RemoteViews getViewAt(int inPosition) {
Log.v(DbgU.getAppTag(), DbgU.getMethodName()
+ ", inPosition = " + inPosition);
//Moving the cursor to the current position
mItemCursor.moveToPosition(inPosition);
//Extracting values from the database
String tmpName = mItemCursor.getString(
mItemCursor.getColumnIndexOrThrow(ItemTableM.COLUMN_NAME));
long tmpItemId = mItemCursor.getLong(
mItemCursor.getColumnIndexOrThrow(ItemTableM.COLUMN_ID));
Uri tmpItemUri = DatabaseU.getItemUriFromId(tmpItemId);
//Setting up the remote views object
RemoteViews retRemoteViews = new RemoteViews(
mContext.getPackageName(), R.layout.widget_listitem);
retRemoteViews.setTextViewText(R.id.widget_listitem_textView, tmpName);
//Adding action URI to the intent template which was set for all the
//list rows in WidgetProviderC.onUpdate
Intent tmpFillInIntent = new Intent();
tmpFillInIntent.setData(tmpItemUri);
retRemoteViews.setOnClickFillInIntent(R.id.widget_listitem_textView,
tmpFillInIntent);
return retRemoteViews;
}
I've been having this problem for a long time and am very grateful for any help
I have also had the same problem for a long time.
On Sony devices that have Android 4.0, if you swipe to another home pane and then back to the one where the widget is, then widget list elements will not be clickable. Sony Android 4.1 and above do not have this problem but sometimes they show wrong list element.
On some Samsung devices that have Android 4.1 I have seen the same problem.
Android 4.0 emulator homescreen does not have this problem.
I have tried to fix it in many ways, also in this way: stackoverflow.com/questions/21891008/a-textview-in-a-listview-s-row-cannot-click-after-setting-descendantfocusabilit
However, I could not fix the problem which lead me to believe that it is a homescreen problem.
To confirm that, I decided to install "Go Launcher" on a Sony Android 4.0 device, and there everything works as it should!
The answer: It is a homescreen problem which is most likely not possible to solve without using some kind of hack. Please tell me I am wrong.
I'm making a mobile application with phonegap and jquery mobile. Everytime I select one of the menu elements I call to a WS that gives me an answer that I show in the screen. It works perfectly up to there.
As I want to have a better view so I use the code trigger ('create'). (http://jquerymobile.com/demos/1.0a4.1/docs/forms/forms-checkboxes.html but insted of refresh I have to make an create)
var listadohtml = '<div data-role="fieldcontain"><fieldset data-role="controlgroup">';
for (var i=0;i<resultado.length;i++){
var item = '';
var id = resultado[i]['id'];
item += '<input type="checkbox" name="checkbox-'+id+'" id="checkbox-'+id+'" class="custom" />';
item += '<label for="checkbox-'+id+'">'+resultado[i]["title"]+'</label>';
listadohtml += item;
}
listadohtml += '</fieldset></div>';
$('#listaPreguntas').html(listadohtml).trigger('create');
Inmediatly after that I associate an event:
$("#listaPreguntas input[type='checkbox']").bind( "click", function(event, ui) {... some code ...});
It shows everything fine, but the problem is that sometimes (not always, that's the problem) when I click a checkbox the green tick is not shown but the event change is made. When it happens I can see, by clicking in other part of the screen, that I have clicked before because it refreshes and shows the tick.
The conclussions I have
It is not the AVD because im making all the tests in my mobile phone with android 4.0.
It appears that its something of the code that includes jquery mobile when I use de trigger.
I think it is not loading time because I can wait for years and it can happens.
As you can see its not a "logic" problem but a usability one.
Thanks in advance!
For checkbox and radio, use change event not click. And keep in mind that attaching events to dynamic elements is different, I have updated my answer accordingly.
Demo
$(document).on('change', '[type=checkbox]', function () {
// code here
});
If the event click fires every time as expected then try to set the check box checked/unchecked classes using addClass and removeClass in your code pragmatically rather than relying on the JQM.