://fp,&quotqtion;\r\nError:%d\r.name,(*q).age);

while(r) { if(strcspn(r-&data.name,findmess)==0) /*若找到findmess值的学生姓名*/ r=r-&next_百度知道
while(r) { if(strcspn(r-&data.name,findmess)==0) /*若找到findmess值的学生姓名*/ r=r-&next
这是学生管理系统中源代码的一部分
做姓名模糊查询的
想做一个循环
使你输入前几个字母时
可以输出带有这前几个字母的所有数据(目前只能输出一个即一次)
p=Locate(l;);
r=r-&if(strcmp(}
两个有关的部分 if(select==2) /
}}return 0:&)==0) /next!;*按姓名查询*/input the e
if(strcspn(r-&gt,&quot,15;*按姓名查询*/{
stringinput(
getchar(),& /
getchar()Node* Locate(L);
return r!){Node *r;press any key to return&name&quot,&
Nofind()!最好能给代码;)==0)
if(strcmp(r-&
}}else if(strcmp(*若找到findmess值的学号*&#47,findmess)==0)
printdata(p);*若找到findmess值的学生姓名*/);*若未找到,char nameornum[])
(;*按学号查询*/
printheader(),&quot,返回一个空指针*&#47,searchinput.{
r=l-&gt!;next!;{
r=l-&name&
return r.data,findmess)==0) /
getchar();num&quot,char findmess[];
printf(END);}else
提问者采纳
然后外边调用的时候循环调用locate函数,上次返回的node×当作下一次传入的参数,直到返回null如果我没理解错你的意思,则从头找,那就几个参数,传入一个node的指针数组就可以还有一个写法是,如果参数为null,加一个node*参数,否则就已node×继续往下找,那么思路就是这样的如果想返回多个
提问者评价
也没别的人回答了
其他类似问题
按默认排序
其他1条回答
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁那首歌叫嘉兴(New Age版)-&80后&amp...
方式一:扫一扫
支持各类二维码扫描软件
方式二:发一发
免费发送App到手机
看不清验证码不正确
该短信不收取任何费用
方式三:下一下
下载App观看
还有更多攻略和游戏礼包等着你
嵌入代码:
这个支持手机播放哦
专区热点·
大家都在看
手机看视频
小闹心°Foreve
家聿(yù)
不一样的情话?当前位置: >
对于教学数据库的三个基本表:S(S#,SNAME,AGE,SEX)、C(C#,CNAME,TEACHER)、SC(S#,C#,GRADE),检索姓&王&的所有学生的学号、姓名和年龄的语句如下:
SELECT&S#,SNAME,AGE
WHERE&() 。
所属学科:
试题类型:客观题
所属知识点:
试题分数:1.0 分
暂无学习笔记。
&&&&&&&&&&&&&&&希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-有些问题与答案
有些问题与答案 
 学习Android的过程中,碰到很多问题,从问题中也学到了很多。
写一个视频播放器的时候,时间尺度的把握让我想了一段时间,进度条的刷新,字幕的刷新都要注意些。MediaPlayer.getduration() return int/millisecond
SeekBar.getProgress() return int/scecondstatic import
javadoc的static import文档在这里。
为了获取静态成员,必须以所在类修饰引它,例如: double r = Math.cos(Math.PI * theta);
为了避开这个问题,把静态成员写入接口并继承它会是一个坏主意,这个主义的名字叫Constant Interface Antipattern,问题是一个类使用另外一个类的静态成员只不过是执行上的细节,当一个类实现了一个接口,那么它成了这个类的public API,而执行细节不应该向public API泄漏的。static import 可以免去这一麻烦,只要
import static java.lang.Math.PI; // import static CLASS_NAME.MEMBER_NAME;
或者& && && && && && && && && && && && && &&&// Alternatively
import static java.lang.Math.*; // import static CLASS_NAME.*;
一旦导入了静态成员,就可以不加修饰地引用了。& &double r = cos(PI * theta);
最后,你必须谨慎使用 static import ,very sparingly 。 当需要频繁引用时,可以使用该特性;滥用会导致你的程序变得不可读不好维护,污染命名空间,
如何开启java断言,问题英文答案在这里,中文的在下面。
导入JUnit Assert类,注意不要导入Junit4 framework,那个是org.junit包,在Android设备或模拟器上你必须使用junit.framework包
import static junit.framework.Assert.*;
然后尽情使用assertTrue, assertEquals, assertNull吧!
开启断言有两种方法:
1. 通过adb shell setprop debug.assert 1来设置系统属性 debug.assert
2. 给Dalvik虚拟机添加命令行参数 --enable-assert 或简写 -ea
指定的APK打开
如果是自己写的播放器,当然知道名字,直接 startActivity(new Intent(HereActivity.this,ThereActivity.class));就行了。如果是用其他人写的apk,就不清楚名字了,怎么办呢?
如果装了多个应用程序,如播放器RockPlayer, VPlayer等等, 但是就是想用RockPlayer打开。
Intent intent = new Intent();
intent.setComponent(new ComponentName(&com.redirectin.rockplayer.android.unified&, &com.redirectin.rockplayer.android.OpenRockPlayerActivity&));
// 包名 类名,解压apk文件,利用网上流传的XMLprinter.jar东西java -jar XMLPrinter AndroidManifest.xml,
// 查AndroidManifest.xml文件内容,当然这样有点小题大做了。
// 简单一点,可以播放视频,选择RockPlayer打开,查看logcat信息,然后提取里面字符串,cmp是ComponentName。Uri name = Uri.parse(&http://192.168.1.122/video.flv&);
intent.setData(name);
startActivity(intent);
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* cmp=android/com.android.internal.app.ResolverActivity }
I/ActivityManager( 1079): Displayed activity android/com.android.internal.app.ResolverActivity: 414 ms (total 414 ms)
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* flg=0x3800000 cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.OpenRockPlayerActivity }
I/ActivityManager( 1079): Starting activity: Intent { cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.RockPlayer (has extras) }
D/dalvikvm(10505): Trying to load lib /data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so 0x4a3cbe90
D/dalvikvm(10505): Shared lib '/data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so' already loaded in same CL 0x4a3cbe90
W/drawable(10505): Bad element under &shape&: background
D/NativeLibName(10505): plugin .so path /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg
D/NativeLibName(10505): ARMv7, idx=8 vfpv3d32=false
D/NativeLibName(10505): degressionLevel=0, path is /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open optimized ffmpeg lib: /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open video height = 720,width=1280
D/RockPlayer(10505): Surface hasn't been initialized! NativeSurfaceView.setSurfaceChanged never got called?
D/RockPlayer(10505): NativeSurfaceView.getVideoHeight: 720
D/RockPlayer(10505): NativeSurfaceView.getVideoWidth: 1280复制代码
image/*的处理
Intent intent = new Intent();
Uri uri = Uri.parse(&/image//beautiful.jpg&);
intent.setDataAndType(uri, &image/*&); // video/* 或者 audio/* 两种试过可以的。
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);运行的话会抛出异常,logcat信息:
ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=/image//beautiful.jpg typ=image/* }
intent.setDataAndType(uri, &image/*&);将其改成intent.setData(uri);会启动浏览器打开图片。
public boolean onItemLongClick(AdapterView&?& parent, View view,int position,long id)
& & // final int pos=
& & @Override
& & public void onClick(DialogInterface dialog, int which)
& && &&&// do something here..
& && &&&// st_color.remove(pos);
}内部匿名类访问外部类变量需要添加final属性。
参数添加final属性不算函数重载,试着将上面的参数修改了成 final int postion,final long id
发现,运行的结果与预期不一致,表现在 lst_color.remove(position); 删除不掉数据
其中,lst_color为ArrayList&String&型数据。
然后关掉注释,即添加 final int pos= lst_color.remove(pos); 成功删除。ArrayList&T&与T[]
ArrayList&T&与T[]之间的转换,用get()方法获取然后对数组赋值显得冗余。
ArrayList&T& lst_
T[] color=(T[])lst_color.toArray(new String[lst_color.length());
lst_color=Arrays.asList(color);  查阅javadoc,ArrayList提供public &T& T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。
  如果指定的数组能容纳列表并有剩余空间(即数组的元素比列表的多),那么会将数组中紧跟在集合末尾的元素设置为 null。这对确定列表的长度很有用,但只在调用方知道列表中不包含任何 null 元素时才有用。
  asList方法返回一个受指定数组支持的固定大小的列表,此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。
Activity与Service数据交互
通过Intent来传递数据Activity使用intent.putExtras(KEY,value);
Service使用public void onStartCommand(Intent data, int startId, int flags),
public void onStart (Intent intent, int startId) This method is deprecated.APK的安装与卸载
// 安装程序的apk文件路径String fileName = Environment.getExternalStorageDirectory() + apkN
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri, application/vnd.android.package-archive&);
startActivity(intent);
// 卸载apk,通过程序的包名创建URI
Uri packageURI = Uri.parse(&package: poet.android.app.id&);
Intent intent = new Intent(Intent.ACTION_DELETE);
startActivity(intent);
我是软件狂
谢谢分享&&希望于楼主多多交流
梦境照进现实
-苹果皮官网
<meta name="keywords" content="有些问题与答案
有些问题与答案 
 学习Android的过程中,碰到很多问题,从问题中也学到了很多。
写一个视频播放器的时候,时间尺度的把握让我想了一段时间,进度条的刷新,字幕的刷新都要注意些。MediaPlayer.getduration() return int/millisecond
SeekBar.getProgress() return int/scecondstatic import
javadoc的static import文档在这里。
为了获取静态成员,必须以所在类修饰引它,例如: double r = Math.cos(Math.PI * theta);
为了避开这个问题,把静态成员写入接口并继承它会是一个坏主意,这个主义的名字叫Constant Interface Antipattern,问题是一个类使用另外一个类的静态成员只不过是执行上的细节,当一个类实现了一个接口,那么它成了这个类的public API,而执行细节不应该向public API泄漏的。static import 可以免去这一麻烦,只要
import static java.lang.Math.PI; // import static CLASS_NAME.MEMBER_NAME;
或者& && && && && && && && && && && && && &&&// Alternatively
import static java.lang.Math.*; // import static CLASS_NAME.*;
一旦导入了静态成员,就可以不加修饰地引用了。& &double r = cos(PI * theta);
最后,你必须谨慎使用 static import ,very sparingly 。 当需要频繁引用时,可以使用该特性;滥用会导致你的程序变得不可读不好维护,污染命名空间,
如何开启java断言,问题英文答案在这里,中文的在下面。
导入JUnit Assert类,注意不要导入Junit4 framework,那个是org.junit包,在Android设备或模拟器上你必须使用junit.framework包
import static junit.framework.Assert.*;
然后尽情使用assertTrue, assertEquals, assertNull吧!
开启断言有两种方法:
1. 通过adb shell setprop debug.assert 1来设置系统属性 debug.assert
2. 给Dalvik虚拟机添加命令行参数 --enable-assert 或简写 -ea
指定的APK打开
如果是自己写的播放器,当然知道名字,直接 startActivity(new Intent(HereActivity.this,ThereActivity.class));就行了。如果是用其他人写的apk,就不清楚名字了,怎么办呢?
如果装了多个应用程序,如播放器RockPlayer, VPlayer等等, 但是就是想用RockPlayer打开。
Intent intent = new Intent();
intent.setComponent(new ComponentName(&com.redirectin.rockplayer.android.unified&, &com.redirectin.rockplayer.android.OpenRockPlayerActivity&));
// 包名 类名,解压apk文件,利用网上流传的XMLprinter.jar东西java -jar XMLPrinter AndroidManifest.xml,
// 查AndroidManifest.xml文件内容,当然这样有点小题大做了。
// 简单一点,可以播放视频,选择RockPlayer打开,查看logcat信息,然后提取里面字符串,cmp是ComponentName。Uri name = Uri.parse(&http://192.168.1.122/video.flv&);
intent.setData(name);
startActivity(intent);
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* cmp=android/com.android.internal.app.ResolverActivity }
I/ActivityManager( 1079): Displayed activity android/com.android.internal.app.ResolverActivity: 414 ms (total 414 ms)
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* flg=0x3800000 cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.OpenRockPlayerActivity }
I/ActivityManager( 1079): Starting activity: Intent { cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.RockPlayer (has extras) }
D/dalvikvm(10505): Trying to load lib /data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so 0x4a3cbe90
D/dalvikvm(10505): Shared lib '/data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so' already loaded in same CL 0x4a3cbe90
W/drawable(10505): Bad element under &shape&: background
D/NativeLibName(10505): plugin .so path /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg
D/NativeLibName(10505): ARMv7, idx=8 vfpv3d32=false
D/NativeLibName(10505): degressionLevel=0, path is /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open optimized ffmpeg lib: /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open video height = 720,width=1280
D/RockPlayer(10505): Surface hasn't been initialized! NativeSurfaceView.setSurfaceChanged never got called?
D/RockPlayer(10505): NativeSurfaceView.getVideoHeight: 720
D/RockPlayer(10505): NativeSurfaceView.getVideoWidth: 1280复制代码
image/*的处理
Intent intent = new Intent();
Uri uri = Uri.parse(&/image//beautiful.jpg&);
intent.setDataAndType(uri, &image/*&); // video/* 或者 audio/* 两种试过可以的。
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);运行的话会抛出异常,logcat信息:
ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=/image//beautiful.jpg typ=image/* }
intent.setDataAndType(uri, &image/*&);将其改成intent.setData(uri);会启动浏览器打开图片。
public boolean onItemLongClick(AdapterView&?& parent, View view,int position,long id)
& & // final int pos=
& & @Override
& & public void onClick(DialogInterface dialog, int which)
& && &&&// do something here..
& && &&&// st_color.remove(pos);
}内部匿名类访问外部类变量需要添加final属性。
参数添加final属性不算函数重载,试着将上面的参数修改了成 final int postion,final long id
发现,运行的结果与预期不一致,表现在 lst_color.remove(position); 删除不掉数据
其中,lst_color为ArrayList&String&型数据。
然后关掉注释,即添加 final int pos= lst_color.remove(pos); 成功删除。ArrayList&T&与T[]
ArrayList&T&与T[]之间的转换,用get()方法获取然后对数组赋值显得冗余。
ArrayList&T& lst_
T[] color=(T[])lst_color.toArray(new String[lst_color.length());
lst_color=Arrays.asList(color);  查阅javadoc,ArrayList提供public &T& T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。
  如果指定的数组能容纳列表并有剩余空间(即数组的元素比列表的多),那么会将数组中紧跟在集合末尾的元素设置为 null。这对确定列表的长度很有用,但只在调用方知道列表中不包含任何 null 元素时才有用。
  asList方法返回一个受指定数组支持的固定大小的列表,此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。
Activity与Service数据交互
通过Intent来传递数据Activity使用intent.putExtras(KEY,value);
Service使用public void onStartCommand(Intent data, int startId, int flags),
public void onStart (Intent intent, int startId) This method is deprecated.APK的安装与卸载
// 安装程序的apk文件路径String fileName = Environment.getExternalStorageDirectory() + apkN
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri, application/vnd.android.package-archive&);
startActivity(intent);
// 卸载apk,通过程序的包名创建URI
Uri packageURI = Uri.parse(&package: poet.android.app.id&);
Intent intent = new Intent(Intent.ACTION_DELETE);
startActivity(intent);
我是软件狂
谢谢分享&&希望于楼主多多交流
梦境照进现实
<meta name="description" content="有些问题与答案
有些问题与答案 
 学习Android的过程中,碰到很多问题,从问题中也学到了很多。
写一个视频播放器的时候,时间尺度的把握让我想了一段时间,进度条的刷新,字幕的刷新都要注意些。MediaPlayer.getduration() return int/millisecond
SeekBar.getProgress() return int/scecondstatic import
javadoc的static import文档在这里。
为了获取静态成员,必须以所在类修饰引它,例如: double r = Math.cos(Math.PI * theta);
为了避开这个问题,把静态成员写入接口并继承它会是一个坏主意,这个主义的名字叫Constant Interface Antipattern,问题是一个类使用另外一个类的静态成员只不过是执行上的细节,当一个类实现了一个接口,那么它成了这个类的public API,而执行细节不应该向public API泄漏的。static import 可以免去这一麻烦,只要
import static java.lang.Math.PI; // import static CLASS_NAME.MEMBER_NAME;
或者& && && && && && && && && && && && && &&&// Alternatively
import static java.lang.Math.*; // import static CLASS_NAME.*;
一旦导入了静态成员,就可以不加修饰地引用了。& &double r = cos(PI * theta);
最后,你必须谨慎使用 static import ,very sparingly 。 当需要频繁引用时,可以使用该特性;滥用会导致你的程序变得不可读不好维护,污染命名空间,
如何开启java断言,问题英文答案在这里,中文的在下面。
导入JUnit Assert类,注意不要导入Junit4 framework,那个是org.junit包,在Android设备或模拟器上你必须使用junit.framework包
import static junit.framework.Assert.*;
然后尽情使用assertTrue, assertEquals, assertNull吧!
开启断言有两种方法:
1. 通过adb shell setprop debug.assert 1来设置系统属性 debug.assert
2. 给Dalvik虚拟机添加命令行参数 --enable-assert 或简写 -ea
指定的APK打开
如果是自己写的播放器,当然知道名字,直接 startActivity(new Intent(HereActivity.this,ThereActivity.class));就行了。如果是用其他人写的apk,就不清楚名字了,怎么办呢?
如果装了多个应用程序,如播放器RockPlayer, VPlayer等等, 但是就是想用RockPlayer打开。
Intent intent = new Intent();
intent.setComponent(new ComponentName(&com.redirectin.rockplayer.android.unified&, &com.redirectin.rockplayer.android.OpenRockPlayerActivity&));
// 包名 类名,解压apk文件,利用网上流传的XMLprinter.jar东西java -jar XMLPrinter AndroidManifest.xml,
// 查AndroidManifest.xml文件内容,当然这样有点小题大做了。
// 简单一点,可以播放视频,选择RockPlayer打开,查看logcat信息,然后提取里面字符串,cmp是ComponentName。Uri name = Uri.parse(&http://192.168.1.122/video.flv&);
intent.setData(name);
startActivity(intent);
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* cmp=android/com.android.internal.app.ResolverActivity }
I/ActivityManager( 1079): Displayed activity android/com.android.internal.app.ResolverActivity: 414 ms (total 414 ms)
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* flg=0x3800000 cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.OpenRockPlayerActivity }
I/ActivityManager( 1079): Starting activity: Intent { cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.RockPlayer (has extras) }
D/dalvikvm(10505): Trying to load lib /data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so 0x4a3cbe90
D/dalvikvm(10505): Shared lib '/data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so' already loaded in same CL 0x4a3cbe90
W/drawable(10505): Bad element under &shape&: background
D/NativeLibName(10505): plugin .so path /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg
D/NativeLibName(10505): ARMv7, idx=8 vfpv3d32=false
D/NativeLibName(10505): degressionLevel=0, path is /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open optimized ffmpeg lib: /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open video height = 720,width=1280
D/RockPlayer(10505): Surface hasn't been initialized! NativeSurfaceView.setSurfaceChanged never got called?
D/RockPlayer(10505): NativeSurfaceView.getVideoHeight: 720
D/RockPlayer(10505): NativeSurfaceView.getVideoWidth: 1280复制代码
image/*的处理
Intent intent = new Intent();
Uri uri = Uri.parse(&/image//beautiful.jpg&);
intent.setDataAndType(uri, &image/*&); // video/* 或者 audio/* 两种试过可以的。
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);运行的话会抛出异常,logcat信息:
ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=/image//beautiful.jpg typ=image/* }
intent.setDataAndType(uri, &image/*&);将其改成intent.setData(uri);会启动浏览器打开图片。
public boolean onItemLongClick(AdapterView&?& parent, View view,int position,long id)
& & // final int pos=
& & @Override
& & public void onClick(DialogInterface dialog, int which)
& && &&&// do something here..
& && &&&// st_color.remove(pos);
}内部匿名类访问外部类变量需要添加final属性。
参数添加final属性不算函数重载,试着将上面的参数修改了成 final int postion,final long id
发现,运行的结果与预期不一致,表现在 lst_color.remove(position); 删除不掉数据
其中,lst_color为ArrayList&String&型数据。
然后关掉注释,即添加 final int pos= lst_color.remove(pos); 成功删除。ArrayList&T&与T[]
ArrayList&T&与T[]之间的转换,用get()方法获取然后对数组赋值显得冗余。
ArrayList&T& lst_
T[] color=(T[])lst_color.toArray(new String[lst_color.length());
lst_color=Arrays.asList(color);  查阅javadoc,ArrayList提供public &T& T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。
  如果指定的数组能容纳列表并有剩余空间(即数组的元素比列表的多),那么会将数组中紧跟在集合末尾的元素设置为 null。这对确定列表的长度很有用,但只在调用方知道列表中不包含任何 null 元素时才有用。
  asList方法返回一个受指定数组支持的固定大小的列表,此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。
Activity与Service数据交互
通过Intent来传递数据Activity使用intent.putExtras(KEY,value);
Service使用public void onStartCommand(Intent data, int startId, int flags),
public void onStart (Intent intent, int startId) This method is deprecated.APK的安装与卸载
// 安装程序的apk文件路径String fileName = Environment.getExternalStorageDirectory() + apkN
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri, application/vnd.android.package-archive&);
startActivity(intent);
// 卸载apk,通过程序的包名创建URI
Uri packageURI = Uri.parse(&package: poet.android.app.id&);
Intent intent = new Intent(Intent.ACTION_DELETE);
startActivity(intent);
我是软件狂
谢谢分享&&希望于楼主多多交流
梦境照进现实
有些问题与答案
有些问题与答案 
 学习Android的过程中,碰到很多问题,从问题中也学到了很多。
写一个视频播放器的时候,时间尺度的把握让我想了一段时间,进度条的刷新,字幕的刷新都要注意些。MediaPlayer.getduration() return int/millisecond
SeekBar.getProgress() return int/scecondstatic import
javadoc的static import文档在这里。
为了获取静态成员,必须以所在类修饰引它,例如: double r = Math.cos(Math.PI * theta);
为了避开这个问题,把静态成员写入接口并继承它会是一个坏主意,这个主义的名字叫Constant Interface Antipattern,问题是一个类使用另外一个类的静态成员只不过是执行上的细节,当一个类实现了一个接口,那么它成了这个类的public API,而执行细节不应该向public API泄漏的。static import 可以免去这一麻烦,只要
import static java.lang.Math.PI; // import static CLASS_NAME.MEMBER_NAME;
或者& && && && && && && && && && && && && &&&// Alternatively
import static java.lang.Math.*; // import static CLASS_NAME.*;
一旦导入了静态成员,就可以不加修饰地引用了。& &double r = cos(PI * theta);
最后,你必须谨慎使用 static import ,very sparingly 。 当需要频繁引用时,可以使用该特性;滥用会导致你的程序变得不可读不好维护,污染命名空间,
如何开启java断言,问题英文答案在这里,中文的在下面。
导入JUnit Assert类,注意不要导入Junit4 framework,那个是org.junit包,在Android设备或模拟器上你必须使用junit.framework包
import static junit.framework.Assert.*;
然后尽情使用assertTrue, assertEquals, assertNull吧!
开启断言有两种方法:
1. 通过adb shell setprop debug.assert 1来设置系统属性 debug.assert
2. 给Dalvik虚拟机添加命令行参数 --enable-assert 或简写 -ea
指定的APK打开
如果是自己写的播放器,当然知道名字,直接 startActivity(new Intent(HereActivity.this,ThereActivity.class));就行了。如果是用其他人写的apk,就不清楚名字了,怎么办呢?
如果装了多个应用程序,如播放器RockPlayer, VPlayer等等, 但是就是想用RockPlayer打开。
Intent intent = new Intent();
intent.setComponent(new ComponentName(&com.redirectin.rockplayer.android.unified&, &com.redirectin.rockplayer.android.OpenRockPlayerActivity&));
// 包名 类名,解压apk文件,利用网上流传的XMLprinter.jar东西java -jar XMLPrinter AndroidManifest.xml,
// 查AndroidManifest.xml文件内容,当然这样有点小题大做了。
// 简单一点,可以播放视频,选择RockPlayer打开,查看logcat信息,然后提取里面字符串,cmp是ComponentName。Uri name = Uri.parse(&http://192.168.1.122/video.flv&);
intent.setData(name);
startActivity(intent);
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* cmp=android/com.android.internal.app.ResolverActivity }
I/ActivityManager( 1079): Displayed activity android/com.android.internal.app.ResolverActivity: 414 ms (total 414 ms)
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* flg=0x3800000 cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.OpenRockPlayerActivity }
I/ActivityManager( 1079): Starting activity: Intent { cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.RockPlayer (has extras) }
D/dalvikvm(10505): Trying to load lib /data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so 0x4a3cbe90
D/dalvikvm(10505): Shared lib '/data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so' already loaded in same CL 0x4a3cbe90
W/drawable(10505): Bad element under &shape&: background
D/NativeLibName(10505): plugin .so path /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg
D/NativeLibName(10505): ARMv7, idx=8 vfpv3d32=false
D/NativeLibName(10505): degressionLevel=0, path is /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open optimized ffmpeg lib: /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open video height = 720,width=1280
D/RockPlayer(10505): Surface hasn't been initialized! NativeSurfaceView.setSurfaceChanged never got called?
D/RockPlayer(10505): NativeSurfaceView.getVideoHeight: 720
D/RockPlayer(10505): NativeSurfaceView.getVideoWidth: 1280复制代码
image/*的处理
Intent intent = new Intent();
Uri uri = Uri.parse(&/image//beautiful.jpg&);
intent.setDataAndType(uri, &image/*&); // video/* 或者 audio/* 两种试过可以的。
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);运行的话会抛出异常,logcat信息:
ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=/image//beautiful.jpg typ=image/* }
intent.setDataAndType(uri, &image/*&);将其改成intent.setData(uri);会启动浏览器打开图片。
public boolean onItemLongClick(AdapterView&?& parent, View view,int position,long id)
& & // final int pos=
& & @Override
& & public void onClick(DialogInterface dialog, int which)
& && &&&// do something here..
& && &&&// st_color.remove(pos);
}内部匿名类访问外部类变量需要添加final属性。
参数添加final属性不算函数重载,试着将上面的参数修改了成 final int postion,final long id
发现,运行的结果与预期不一致,表现在 lst_color.remove(position); 删除不掉数据
其中,lst_color为ArrayList&String&型数据。
然后关掉注释,即添加 final int pos= lst_color.remove(pos); 成功删除。ArrayList&T&与T[]
ArrayList&T&与T[]之间的转换,用get()方法获取然后对数组赋值显得冗余。
ArrayList&T& lst_
T[] color=(T[])lst_color.toArray(new String[lst_color.length());
lst_color=Arrays.asList(color);  查阅javadoc,ArrayList提供public &T& T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。
  如果指定的数组能容纳列表并有剩余空间(即数组的元素比列表的多),那么会将数组中紧跟在集合末尾的元素设置为 null。这对确定列表的长度很有用,但只在调用方知道列表中不包含任何 null 元素时才有用。
  asList方法返回一个受指定数组支持的固定大小的列表,此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。
Activity与Service数据交互
通过Intent来传递数据Activity使用intent.putExtras(KEY,value);
Service使用public void onStartCommand(Intent data, int startId, int flags),
public void onStart (Intent intent, int startId) This method is deprecated.APK的安装与卸载
// 安装程序的apk文件路径String fileName = Environment.getExternalStorageDirectory() + apkN
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri, application/vnd.android.package-archive&);
startActivity(intent);
// 卸载apk,通过程序的包名创建URI
Uri packageURI = Uri.parse(&package: poet.android.app.id&);
Intent intent = new Intent(Intent.ACTION_DELETE);
startActivity(intent);
我是软件狂
谢谢分享&&希望于楼主多多交流
梦境照进现实
数据库技术
综合交流区
站务及频道
查看完整版本:
有些问题与答案
有些问题与答案 
 学习Android的过程中,碰到很多问题,从问题中也学到了很多。
写一个视频播放器的时候,时间尺度的把握让我想了一段时间,进度条的刷新,字幕的刷新都要注意些。MediaPlayer.getduration() return int/millisecond
SeekBar.getProgress() return int/scecondstatic import
javadoc的static import文档在这里。
为了获取静态成员,必须以所在类修饰引它,例如: double r = Math.cos(Math.PI * theta);
为了避开这个问题,把静态成员写入接口并继承它会是一个坏主意,这个主义的名字叫Constant Interface Antipattern,问题是一个类使用另外一个类的静态成员只不过是执行上的细节,当一个类实现了一个接口,那么它成了这个类的public API,而执行细节不应该向public API泄漏的。static import 可以免去这一麻烦,只要
import static java.lang.Math.PI; // import static CLASS_NAME.MEMBER_NAME;
或者& && && && && && && && && && && && && &&&// Alternatively
import static java.lang.Math.*; // import static CLASS_NAME.*;
一旦导入了静态成员,就可以不加修饰地引用了。& &double r = cos(PI * theta);
最后,你必须谨慎使用 static import ,very sparingly 。 当需要频繁引用时,可以使用该特性;滥用会导致你的程序变得不可读不好维护,污染命名空间,
如何开启java断言,问题英文答案在这里,中文的在下面。
导入JUnit Assert类,注意不要导入Junit4 framework,那个是org.junit包,在Android设备或模拟器上你必须使用junit.framework包
import static junit.framework.Assert.*;
然后尽情使用assertTrue, assertEquals, assertNull吧!
开启断言有两种方法:
1. 通过adb shell setprop debug.assert 1来设置系统属性 debug.assert
2. 给Dalvik虚拟机添加命令行参数 --enable-assert 或简写 -ea
指定的APK打开
如果是自己写的播放器,当然知道名字,直接 startActivity(new Intent(HereActivity.this,ThereActivity.class));就行了。如果是用其他人写的apk,就不清楚名字了,怎么办呢?
如果装了多个应用程序,如播放器RockPlayer, VPlayer等等, 但是就是想用RockPlayer打开。
Intent intent = new Intent();
intent.setComponent(new ComponentName(&com.redirectin.rockplayer.android.unified&, &com.redirectin.rockplayer.android.OpenRockPlayerActivity&));
// 包名 类名,解压apk文件,利用网上流传的XMLprinter.jar东西java -jar XMLPrinter AndroidManifest.xml,
// 查AndroidManifest.xml文件内容,当然这样有点小题大做了。
// 简单一点,可以播放视频,选择RockPlayer打开,查看logcat信息,然后提取里面字符串,cmp是ComponentName。Uri name = Uri.parse(&http://192.168.1.122/video.flv&);
intent.setData(name);
startActivity(intent);
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* cmp=android/com.android.internal.app.ResolverActivity }
I/ActivityManager( 1079): Displayed activity android/com.android.internal.app.ResolverActivity: 414 ms (total 414 ms)
I/ActivityManager( 1079): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/video/Crysis2DirectX11UltraUpgradeTrailer_H.264%20AVC_.flv typ=video/* flg=0x3800000 cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.OpenRockPlayerActivity }
I/ActivityManager( 1079): Starting activity: Intent { cmp=com.redirectin.rockplayer.android.unified/com.redirectin.rockplayer.android.RockPlayer (has extras) }
D/dalvikvm(10505): Trying to load lib /data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so 0x4a3cbe90
D/dalvikvm(10505): Shared lib '/data/data/com.redirectin.rockplayer.android.unified/lib/librockplayer_8.so' already loaded in same CL 0x4a3cbe90
W/drawable(10505): Bad element under &shape&: background
D/NativeLibName(10505): plugin .so path /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg
D/NativeLibName(10505): ARMv7, idx=8 vfpv3d32=false
D/NativeLibName(10505): degressionLevel=0, path is /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open optimized ffmpeg lib: /data/data/com.redirectin.rockplayer.android.unified/lib/libffmpeg_7n.so
D/RockPlayer(10505): open video height = 720,width=1280
D/RockPlayer(10505): Surface hasn't been initialized! NativeSurfaceView.setSurfaceChanged never got called?
D/RockPlayer(10505): NativeSurfaceView.getVideoHeight: 720
D/RockPlayer(10505): NativeSurfaceView.getVideoWidth: 1280复制代码
image/*的处理
Intent intent = new Intent();
Uri uri = Uri.parse(&/image//beautiful.jpg&);
intent.setDataAndType(uri, &image/*&); // video/* 或者 audio/* 两种试过可以的。
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);
startActivity(intent);运行的话会抛出异常,logcat信息:
ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=/image//beautiful.jpg typ=image/* }
intent.setDataAndType(uri, &image/*&);将其改成intent.setData(uri);会启动浏览器打开图片。
public boolean onItemLongClick(AdapterView&?& parent, View view,int position,long id)
& & // final int pos=
& & @Override
& & public void onClick(DialogInterface dialog, int which)
& && &&&// do something here..
& && &&&// st_color.remove(pos);
}内部匿名类访问外部类变量需要添加final属性。
参数添加final属性不算函数重载,试着将上面的参数修改了成 final int postion,final long id
发现,运行的结果与预期不一致,表现在 lst_color.remove(position); 删除不掉数据
其中,lst_color为ArrayList&String&型数据。
然后关掉注释,即添加 final int pos= lst_color.remove(pos); 成功删除。ArrayList&T&与T[]
ArrayList&T&与T[]之间的转换,用get()方法获取然后对数组赋值显得冗余。
ArrayList&T& lst_
T[] color=(T[])lst_color.toArray(new String[lst_color.length());
lst_color=Arrays.asList(color);  查阅javadoc,ArrayList提供public &T& T[] toArray(T[] a)方法返回一个按照正确的顺序包含此列表中所有元素的数组;返回数组的运行时类型就是指定数组的运行时类型。如果列表能放入指定的数组,则返回放入此列表元素的数组。否则,将根据指定数组的运行时类型和此列表的大小分配一个新的数组。
  如果指定的数组能容纳列表并有剩余空间(即数组的元素比列表的多),那么会将数组中紧跟在集合末尾的元素设置为 null。这对确定列表的长度很有用,但只在调用方知道列表中不包含任何 null 元素时才有用。
  asList方法返回一个受指定数组支持的固定大小的列表,此方法同 Collection.toArray 一起,充当了基于数组的 API 与基于 collection 的 API 之间的桥梁。返回的列表是可序列化的,并且实现了 RandomAccess。
Activity与Service数据交互
通过Intent来传递数据Activity使用intent.putExtras(KEY,value);
Service使用public void onStartCommand(Intent data, int startId, int flags),
public void onStart (Intent intent, int startId) This method is deprecated.APK的安装与卸载
// 安装程序的apk文件路径String fileName = Environment.getExternalStorageDirectory() + apkN
Uri uri = Uri.fromFile(new File(fileName));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri, application/vnd.android.package-archive&);
startActivity(intent);
// 卸载apk,通过程序的包名创建URI
Uri packageURI = Uri.parse(&package: poet.android.app.id&);
Intent intent = new Intent(Intent.ACTION_DELETE);
startActivity(intent);
我是软件狂
谢谢分享&&希望于楼主多多交流
梦境照进现实
谢谢分享&&希望于楼主多多交流
查看完整版本:

我要回帖

更多关于 quotqtion 的文章

 

随机推荐