導航:首頁 > 操作系統 > android循環

android循環

發布時間:2022-05-03 02:37:04

android 線程的循環

設置標記變數,while(isValid){} 如果想退出的時候,將isValid置為false

② Android開發中 循環命令 怎麼 循環一次先後執行兩條命令

1. 下載sdk時下載了docs/reference文檔,文檔是html形式的,因為裡面帶有google的相關網址,瀏覽器打開時會去訪問這些被牆的網址,所以顯示巨慢。
2. 解決辦法就是遍歷子目錄刪除google相關網址,由於是android開發,就用java實現吧.

③ android 如何正確循環刪除list中的數據

當我們使用for循環刪除列表中的數據的時候,會存在問題,因為ArrayList的父類AbstractList里有個modCount的欄位記錄著List的總數,for循環的時候如果增加或者刪除了元素,(修改不會影響),此欄位會變化,那麼在下次for循環的時候檢查到跟之前的長度不同,此時會報異常。
解決方法如下:
Iterator it=lists.iterator();
while(it.hasNext){
it.next();
if(true){
it.remove();
}
}

④ android studio中怎麼快速生成for循環語句

需要自定義代碼塊,自定義代碼塊步驟:

  1. 點擊「Settings——>Editor——>Live Templates」右邊的「+」號

  2. 可以選擇Live Template或Template Group,Live Template默認當前對應添加的模塊

  3. Template Group為添加的模塊名稱分組,比如:CustomGroup,然後選中該分組後添加Live Template

  4. 在Template text中輸入for循環結構體,Abbreviation設置快捷輸入for:

  5. for(inti=0;i<a.length;i++){};

⑤ 有Android的可以循環播放的手機視頻軟體嗎

MX Player pro。

⑥ Android開發音樂播放器,如何實現單曲循環,順序播放,隨機播放,全部循環功能,高分求助

MediaPlayer 對象調用setLooping(true);是循環播放。
順序播放,隨機播放,全部循環功能 這些就是自己寫方法實現就好了,
順序播放就是當一首歌播放完後,在播放列表中找到它下一首歌的ID,直到全部完成。
隨機播放就是當一首歌播放完後,在播放列表中隨機抽取一首歌的ID(排除已經播放),直到全部完成。
全部循環就是順序播放全部歌曲,到最後一首之後從第一首播放。

⑦ 怎麼能讓安卓手機視頻無限循環播放

現在華為的手機已經可以實現這一功能了,其它手機我不清楚能不能實現:
點開(圖庫),點開(視頻),點開某一段視頻,點播放,點右上角的三個小點,出來一個頁面,點上面的(播放設置)的(單片循環),然後就可以看到該視頻不斷重復播放了。如果有多個視頻想一起播放,也可以點(播放設置)的(全部循環),就全部播放,循環不停。

⑧ android循環取ListView中的數據

只需要循環一下,判斷即可。

示例代碼:
1.遍歷整個list集合
for(int i=0; i<list.size(); i++){
}
2.在for循環中增加判斷代碼
if(list.get(i).equals("指定")){}

3.得到每一個item進行判斷即可。

安卓系統桌面循環滾動桌面設置的

1、手機設置」的「輔助功能」中有選擇是否「桌面循環」。
2、在原生的android源碼上添加這一功能。
思路:先把界面做出來,再將是否選擇的值存到系統的(adb shell進入)data/data/com.android.providers.settings/databases/settings.db資料庫中的system表中,
然後在Launch2的源碼中取得資料庫中是否選擇循環桌面來執行相關代碼。
先做UI:
在settings源碼中的accessibility_settings.xml文件中添加一個checkbox:
java代碼
android:key="launch_repeat"
android:title="@string/launch_repeat_title"
android:persistent="false"/>

在settings源碼的res中添加相關的代碼:
在values/string.xml中添加(英文顯示):
Launch Repeat
在values-zh-rCN/string.xml中添加(中文顯示):
"循環桌面"
在settings源碼的AccessibilitySettings.java中的OnCreate中添加:
java代碼
/*****************************************/

mLaunchRepeat=(CheckBoxPreference) findPreference(
LAUNCH_REPEAT);
int LaunchRepeat=Settings.System.getInt(this.getContentResolver(),
"launch_repeat",0);//取出是否被選擇
if(LaunchRepeat==1)//如果被選擇,那麼下次打開setting時就勾選
mLaunchRepeat.setChecked(true);
else
mLaunchRepeat.setChecked(false);//如果沒被選擇,那麼下次打開setting時就不勾選
/*****************************************/
當然還要定義幾個量:
private final String LAUNCH_REPEAT =
"launch_repeat";
private CheckBoxPreference mLaunchRepeat;

在onPreferenceTreeClick函數中添加:
java代碼
//add by xxnan

if(LAUNCH_REPEAT.equals(key))
{
Settings.System.putInt(getContentResolver(),
"launch_repeat",
((CheckBoxPreference) preference).isChecked()?
1:0);//將是否選擇存到系統的system表中
}
//add by xxnan

如果做好了之後當點擊選擇「桌面循環時」可以到(adb shell進入)data/data/com.android.providers.settings/databases下的settings.db資料庫(sqlite3 settings.db)的system
表中看到33|launch_repeat|1(select * from system;)。
到這里就完成了將數據存到系統system表中以及UI,接下來就是在Launch2源碼中去取這個值(是否循環)。
到Launcher2源碼中去找到Workspace.java文件,在裡面有相應的修改:
在onTouchEvent中,之前有修改循環,如下:
java代碼
case MotionEvent.ACTION_UP:

if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
/***********************************************/
//下面是原生代碼
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;

那麼就要在修改的地方加一個判斷,如果system中取得的值是1,就可以循環,如果是0,就不能。
代碼修改如下:
java代碼
case MotionEvent.ACTION_UP:

if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
final int velocityX = (int)
velocityTracker.getXVelocity(mActivePointerId);
final int screenWidth = getWidth();
final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
final float scrolledPos = (float) mScrollX / screenWidth;
Log.i("velocityX","velocityX="+velocityX+"whichScreen="+whichScreen);
/***********************************************/
//modifided by xxnan 2013-1-9
launch_repeat=Settings.System.getInt(mContext.getContentResolver(),
"launch_repeat",0);//取出system表中「launch_repeat」的值
Log.i(" launch_repeat"," launch_repeat="+ launch_repeat);
if(launch_repeat==1)//如果是1,就循環,也就是之前已經改好的
{
if (velocityX > SNAP_VELOCITY) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
Log.i("numscreen","numscreen="+mCurrentScreen);
/* final int bound = scrolledPos < whichScreen ?
( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount():
mCurrentScreen;*/
final int bound =( (mCurrentScreen+ getChildCount()) - 1 )% getChildCount()
;
Log.i("numscreen","bound="+bound);
snapToScreen( bound, velocityX, true);
} else if (velocityX < -SNAP_VELOCITY ) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
/*final int bound = scrolledPos > whichScreen ?
( mCurrentScreen + 1 )% getChildCount(): mCurrentScreen;*/
final int bound = ( mCurrentScreen + 1 )% getChildCount() ;
snapToScreen(bound, velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
else//如果是0,那麼就是原生代碼,不循環
{
if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}
}
/***********************************************/
//下面是原生代碼
/*if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
// Fling hard enough to move left.
// Don't fling across more than one screen at a time.
final int bound = scrolledPos < whichScreen ?
mCurrentScreen - 1 : mCurrentScreen;
snapToScreen(Math.min(whichScreen, bound), velocityX, true);
} else if (velocityX < -SNAP_VELOCITY && mCurrentScreen <
getChildCount() - 1) {
// Fling hard enough to move right
// Don't fling across more than one screen at a time.
final int bound = scrolledPos > whichScreen ?
mCurrentScreen + 1 : mCurrentScreen;
snapToScreen(Math.max(whichScreen, bound), velocityX, true);
} else {
snapToScreen(whichScreen, 0, true);
}*/
}
mTouchState = TOUCH_STATE_REST;
mActivePointerId = INVALID_POINTER;
releaseVelocityTracker();
break;

當然這裡面也要定義幾個量,以及導入幾個包:
導入包:
//add by xxnan
import android.content.ContentResolver;//從system表中取數據
import android.provider.Settings;
定義變數:
private int launch_repeat;//取得是否循環的值
到這里就全部修改好了,還有就是編譯一下源碼中的package/apps的Launch2和Settings的源碼,將生成的out/target/。。。/system/app下的
Launch2.apk和Settings.apk替換手機里system/app的這兩個apk就可以了。

⑩ android兩個animation無限循環怎麼做

據我所知,想直接給AnimationSet設置重復,是不行的。不過你可以這樣來:

final int transDuration = 2000;
final int alphaDuration = 1000;

AnimationSet set = new AnimationSet(false);
set.setRepeatMode(Animation.RESTART);

TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 0, 300);
translateAnimation.setInterpolator(new Interpolator() {
@Override
public float getInterpolation(float arg0) {
float ret = arg0 / (1.0f * transDuration / (transDuration + alphaDuration));
return ret < 1 ? ret : 1;
}
});
translateAnimation.setRepeatCount(Animation.INFINITE);
translateAnimation.setDuration(transDuration + alphaDuration);

AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
alphaAnimation.setRepeatCount(Animation.INFINITE);
alphaAnimation.setDuration(alphaDuration);
alphaAnimation.setStartOffset(transDuration);

set.addAnimation(translateAnimation);
set.addAnimation(alphaAnimation);
view.startAnimation(set);

或者像其他所說的,通過在一個動畫結束後開始另外一個動畫的方式。

閱讀全文

與android循環相關的資料

熱點內容
連漲啟動源碼 瀏覽:161
小奔運動app網路異常怎麼回事 瀏覽:447
php開啟壓縮 瀏覽:303
伺服器主機如何設置啟動 瀏覽:282
linux配置網路命令 瀏覽:774
一張照片怎麼製作視頻app 瀏覽:908
pythonweb和php 瀏覽:976
電腦伺服器地址ip地址 瀏覽:823
對矩陣壓縮是為了 瀏覽:910
setfacl命令 瀏覽:172
linux子系統中斷 瀏覽:342
linux查看進程ps 瀏覽:224
知識庫系統php 瀏覽:623
小波變換壓縮圖像python 瀏覽:151
阿里巴巴程序員怎麼月入百萬 瀏覽:173
如何使用國外伺服器 瀏覽:188
燃燈者pdf 瀏覽:468
編譯器用數學嗎 瀏覽:7
圖形化apk反編譯工具 瀏覽:48
考勤表加密怎麼辦 瀏覽:736