首先,我知道这次被问了好几次,但是在较新的android平台上,看起来建议的解决方案不起作用(正如其他人所说的那样).我需要我的微调器仍然调用OnItemSelected,即使用户选择了两次相同的项目.我已经设法找到这个应该做的伎俩:
public class NDSpinner extends Spinner {
private int lastSelected = 0;
private static Method s_pSelectionChangedMethod = null;
static {
try {
Class noparams[] = {};
Class targetClass = AdapterView.class;
s_pSelectionChangedMethod = targetClass.getDeclaredMethod("selectionChanged", noparams);
if (s_pSelectionChangedMethod != null) {
s_pSelectionChangedMethod.setAccessible(true);
}
} catch( Exception e ) {
Log.e("Custom spinner, reflection bug:", e.getMessage());
throw new RuntimeException(e);
}
}
public NDSpinner(Context context) {
super(context);
}
public NDSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NDSpinner(Context context, AttributeSet attrs, int defStyle) { …
Run Code Online (Sandbox Code Playgroud) 在我的 android 设备上,我需要从内容 uri 中提取一个文件(一个 xapk,据我所知,这是一个普通的 zip 存档)。我正在使用以下代码行创建 ZipInputStream:
ZipInputStream zis = new ZipInputStream(getContentResolver().openInputStream(zipUri));
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用以下命令读取存档的第一个条目:
ZipEntry entry = zis.getNextEntry()
Run Code Online (Sandbox Code Playgroud)
问题是我得到了这个异常:
java.util.zip.ZipException:只有 DEFLATED 条目可以有 EXT 描述符
我 100% 确定存档中没有 0bytes 文件,并且我可以使用设备中的其他实用程序(RAR、解压缩等)提取相同的存档。
如果我使用带有硬编码路径的 ZipFile(因此不涉及内容 uri),我可以毫无问题地提取相同的存档,因此问题与带有 uri 的 ZipInputStream 相关。另一方面,我不能在这里使用 ZipFile,因为它不支持内容 uri。
我要在GCC中使用#pragma pack(pop,1),但是当我编译时,我会收到此警告:
格式错误的'#pragma pack(pop [,id])' - 忽略
任何人都可以告诉我这是否是一个很好的解决方案:
#pragma pack(pop)
#pragma pack(1)
Run Code Online (Sandbox Code Playgroud)
非常感谢你 :)