摘录如下
function CartForm($scope,$cookieStore) {
$scope.invoice = {
items: [{
qty: 10,
description: 'item',
cost: 9.95}]
};
//want to add the above array to cookie store here
}
Run Code Online (Sandbox Code Playgroud)
我如何将上面的数组放入cookiestore,然后访问它并绑定它?
创建一个MediaPlayer.特定类具有播放,暂停和恢复的功能.我正在尝试制作一个SeekBar能显示进度的东西.
SeekBar要求作为maxlength从getDuration()调用mediaplayer.getDuration()函数的函数获得的值并返回该值.
SeekBar还需要从getCurrentPostion()函数中获得的当前位置的值.他们俩都回来了NullPointerException.
public class PlayMedia extends AsyncTask<Void, Void, Void>
implements MediaPlayer.OnPreparedListener {
private MediaPlayer mediaPlayer;
int length;
int duration =0;
int currentPosition=0;
@Override
protected Void doInBackground(Void... params) {
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(Environment.getExternalStorageDirectory().getAbsolutePath().toString()+"/Notate/"+MainActivity.filepath+".wav");
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
}
return null;
}
@Override
protected void onPostExecute(Void …Run Code Online (Sandbox Code Playgroud) 我在列表中存储了一组字符串.我遍历列表以与字符串进行比较"[the]".
当我使用该函数时strings.EqualFold,它会出现此错误:
不能在函数参数中使用e.Value(type interface {})作为类型字符串:need type assertion
代码如下:
for e := l.Front(); e != nil; e = e.Next() {
if(strings.EqualFold("[the]", e.Value)){
count++
}
}
Run Code Online (Sandbox Code Playgroud) 我需要一个简单的方法来将所需的参数传递给一个接受多个参数的函数.
def sample1(arg1=0,arg2=0,arg3=0 ... ... argn=0)
Run Code Online (Sandbox Code Playgroud)
参数词典
argument_dictionary={'arg1':0,'arg4':1}
Run Code Online (Sandbox Code Playgroud)
我想遍历argument_dictionary并仅将arg1和arg4传递给sample1 as
sample1(arg1=0,arg4=1)
Run Code Online (Sandbox Code Playgroud)