[android-developers] Re: Andrlid ListView focus mess up with two focusable items in each row

2011-12-11 Thread yanguoc...@gmail.com
Thanks for the tip. But since the new data is coming back from server,
I need to update the UI instead of just updating some of the data set,
since now the data in the listview is more when some new data is
coming back from server.

On Dec 9, 6:45 pm, Kostya Vasilyev kmans...@gmail.com wrote:
 You don't really have to go through notifyDataSetChanged to update the UI.

 If you know that the set of items stays the same (i.e. only their data
 changed), you can iterate the listview's children and update them
 bypassing the adapter.

 -- Kostya

 09.12.2011 14:10, yanguoc...@gmail.com пишет:

  Thanks. But seems hard to maintain focus in a listview before and
  after the latyout pass. I check the source code of listview, it did
  something that may broke the focus in layout pass.

  On Dec 9, 5:46 am, lbendlinl...@bendlin.us  wrote:
  you will need to remember (per row) which item has focus, and when the list
  adapter reloads you will have to apply that knowledge and set
  requestFocus() to the appropriate item.

 --
 Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Andrlid ListView focus mess up with two focusable items in each row

2011-12-09 Thread yanguoc...@gmail.com
Thanks. But seems hard to maintain focus in a listview before and
after the latyout pass. I check the source code of listview, it did
something that may broke the focus in layout pass.

On Dec 9, 5:46 am, lbendlin l...@bendlin.us wrote:
 you will need to remember (per row) which item has focus, and when the list
 adapter reloads you will have to apply that knowledge and set
 requestFocus() to the appropriate item.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Andrlid ListView focus mess up with two focusable items in each row

2011-12-08 Thread yanguoc...@gmail.com
In my application, I want to implement a ListView, of each itemview is
a LinearLayout with two focusable buttons in it horziontally, and each
row item data loads from server in page. But it seems that when
adapter.notifyDataSetChanged is invoked, if the focus is on the right
button of the itemview, it will jump to the left button. Any way I can
make the focus stable ?

Following is my sample code to reproduce the problem. Any one can help
give some suggestion? Thanks.

package com.listviewfocus;

import java.util.Vector;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;

public class SimpleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ListView list = new ListView(this);
final MyAdapter adapter = new MyAdapter();

list.setItemsCanFocus(true);
list.setAdapter(adapter);

setContentView(list);

final Handler handler = new Handler();

new Thread(new Runnable(){
public void run() {
while(true) {
handler.post(new Runnable() {
public void run() {
adapter.addItem(System.currentTimeMillis()
+);
}
});

try {
Thread.currentThread().sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}).start();
}

class MyAdapter extends BaseAdapter {

private VectorString items = new VectorString();

public MyAdapter() {

}

public void addItem(String s) {
items.add(s);
this.notifyDataSetChanged();
}

@Override
public int getCount() {
return items.size();
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup
parent) {

LinearLayout view;

if (convertView instanceof LinearLayout) {
view = (LinearLayout) convertView;
} else {
view = new LinearLayout(parent.getContext());
Button b1 = new Button(parent.getContext());
Button b2 = new Button(parent.getContext());
view.addView(b1);
view.addView(b2);
}

((Button)(((ViewGroup)
view).getChildAt(0))).setText(position+:b1);
((Button)(((ViewGroup)
view).getChildAt(1))).setText(position+:b2);

return view;
}

}

}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] How to detect camera support autofocus from 1.5+

2011-08-18 Thread yanguoc...@gmail.com
I am developing a feature that need camera's autofocus. If the device
does not support AF, then I will not show that feature. There are two
ways I know to detect AF.

One is using Camera.Parameter, but that need to open camera first and
will be slow and give a little bit sound when openning.

The other is use PackageManager.FEATURE_CAMERA_AUTOFOCUS, but it is a
level 7 API.But my application needs to support from 1.5+.

We all know that we can declare uses-feature
android:name=android.hardware.camera.autofocus
android:required=false / in AndroidManifest.xml from 1.5+. So I
wonder any API that can get this during runtime?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] a bug in android gmail application

2010-09-07 Thread yanguoc...@gmail.com
I have an implementation that just like gmail application, but have
met some problem in some case. And I tested it on the real device of
the gmail application. Seems they are caused by the same reason.
ListView.

Just go to the gmail application, scroll down to the last visible
mail, and at this time, make sure the loading conversation at the
bottom is still on. Then long press the last one mail, and the context
menu show up. Then wait for the background email loading finish ( you
can see that the scrollbar move up ). Then you do some action in the
context menu, say read the mail. However, the show up mail is not
the one that I long pressed.

After some debug, I found that this should be related to ListView and
its adapter's getView method, the convert view is reused when the
context menu is shown, and in that case the listItemview has some
field to record the index of the mail, while getView method is
invoked, the field has been changed.

Any one can provide a better way to solve this problem ?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] question about CacheManager.CacheResult

2009-02-12 Thread yanguoc...@gmail.com

I want to intercept the request from webview and use the cache html
page instead sending a real web request. I alos find a
CacheManager.CacheResult and UrlInterceptHandler. The class implements
UrlInterceptHandler did work, it can intecept the request. However, I
fonud no way to generate a CacheResult that contains the local page
back. The document gives almost no clue for the above classes usage.

Did someone can help? Or just another solution that can solve the
problem?

Thanks a lot.

Ps. My android sdk is windows-1.0_r1.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---