根据图库的位置,一个或另一个edittext将获得焦点。虽然我可以做到,行为的画廊崩溃:当画廊运行一个位置并将焦点放在edittext上时,画廊的速度会崩溃。似乎Gallery太慢,无法按时收到请求。
我没有找到任何有关它的重要信息。
galleryView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(
@SuppressWarnings("rawtypes") AdapterView adapterView,
View view, int pos, long l) {
if (pos == 0) {
pie_foto_1.post(new Runnable() {
public void run() {
pie_foto_1.requestFocus();
}
});
}
if (pos == 1) {
pie_foto_2.post(new Runnable() {
public void run() {
pie_foto_2.requestFocus();
}
});
}
if (pos == 2) {
pie_foto_3.post(new Runnable() {
public void run() {
pie_foto_3.requestFocus();
}
});
pie_foto_1.setVisibility(View.INVISIBLE);
pie_foto_2.setVisibility(View.INVISIBLE);
pie_foto_3.setVisibility(View.VISIBLE);
}
}
public void onNothingSelected(
@SuppressWarnings("rawtypes") AdapterView adapterView
) {
}
});
答案 0 :(得分:0)
画廊需要更多时间来获得新职位。所以我在Gallery改变位置之前放了一个延迟,以便获得一个很好的过渡。
else if (pos == 1)
{
Runnable mMyRunnable = new Runnable() {
public void run() {
pie_foto_1.post(new Runnable() {
public void run() {
pie_foto_2.requestFocus();
// headline.clearFocus();
}
});
}
};
Handler myHandler = new Handler();
myHandler.postDelayed(mMyRunnable, 100);
}