jjzjj

classCastException

全部标签

Android - ClassCastException - 在从 LinearLayout 到 AbsListView 的 LayoutParams

我有一个列表适配器,我正在尝试为(item.xml)设置自定义xml如果我不使用通货膨胀(通过应用程序上下文直接识别TextView),它可以完美地工作..但是我的ListView不能被主题化..publicViewgetView(intposition,ViewconvertView,ViewGroupparent){//System.gc();TextViewtv;LayoutInflaterinflater=getLayoutInflater();Viewrow=View.inflate(mContext,R.layout.item,null);//.inflate(R.layo

Android - ClassCastException - 在从 LinearLayout 到 AbsListView 的 LayoutParams

我有一个列表适配器,我正在尝试为(item.xml)设置自定义xml如果我不使用通货膨胀(通过应用程序上下文直接识别TextView),它可以完美地工作..但是我的ListView不能被主题化..publicViewgetView(intposition,ViewconvertView,ViewGroupparent){//System.gc();TextViewtv;LayoutInflaterinflater=getLayoutInflater();Viewrow=View.inflate(mContext,R.layout.item,null);//.inflate(R.layo

android - FrameLayout to RelativeLayout ClassCastException 即使没有使用 FrameLayout

在我的应用程序中,我有一个布局,它有一个RelativeLayout我想在运行时以编程方式设置边距。但是当我这样做时,它给了我ClassCastException说FrameLayout不能转换为RelativeLayout。我没有使用任何FrameLayout,也没有FrameLayout的导入。问题仍然存在。我使用的xml是:.........这是我的onCreate,我将边距设置为父布局:/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){su

android - FrameLayout to RelativeLayout ClassCastException 即使没有使用 FrameLayout

在我的应用程序中,我有一个布局,它有一个RelativeLayout我想在运行时以编程方式设置边距。但是当我这样做时,它给了我ClassCastException说FrameLayout不能转换为RelativeLayout。我没有使用任何FrameLayout,也没有FrameLayout的导入。问题仍然存在。我使用的xml是:.........这是我的onCreate,我将边距设置为父布局:/**Calledwhentheactivityisfirstcreated.*/@OverridepublicvoidonCreate(BundlesavedInstanceState){su

java.lang.ClassCastException : libcore.net.http.HttpURLConnectionImpl 无法转换为 javax.net.ssl.HttpsURLConnection

我正在编写一些代码以通过HTTPS将文件从设备上传到云端。相关fragment:HttpsURLConnectionconn=null;URLurl=newURL(urlstring);conn=(HttpsURLConnection)url.openConnection();//exceptionhere.但是Actor阵容不会编译:06-2015:58:05.311:E/FNF(30286):java.lang.ClassCastException:libcore.net.http.HttpURLConnectionImplcannotbecasttojavax.net.ssl.H

java.lang.ClassCastException : libcore.net.http.HttpURLConnectionImpl 无法转换为 javax.net.ssl.HttpsURLConnection

我正在编写一些代码以通过HTTPS将文件从设备上传到云端。相关fragment:HttpsURLConnectionconn=null;URLurl=newURL(urlstring);conn=(HttpsURLConnection)url.openConnection();//exceptionhere.但是Actor阵容不会编译:06-2015:58:05.311:E/FNF(30286):java.lang.ClassCastException:libcore.net.http.HttpURLConnectionImplcannotbecasttojavax.net.ssl.H

android - SharedPreferences.getInt() 导致 ClassCastException - 为什么?

我在首选项XML中定义了一个简单的(用户不可编辑的)数字设置,如下所示:我用这个简单的语句阅读它:sharedPrefs.getInt(getString(R.string.numeric_val),3)它可以工作,但是当我尝试阅读它时,在应用程序安装后第一次,它会生成ClassCastException.documentation说getInt()“如果此名称的首选项不是int,则抛出ClassCastException。”-我知道此首选项已明确定义为(字符串?)但是,如果这是异常的原因,我应该如何使用SharedPreferences.getInt()?我知道我可以使用Shared

android - SharedPreferences.getInt() 导致 ClassCastException - 为什么?

我在首选项XML中定义了一个简单的(用户不可编辑的)数字设置,如下所示:我用这个简单的语句阅读它:sharedPrefs.getInt(getString(R.string.numeric_val),3)它可以工作,但是当我尝试阅读它时,在应用程序安装后第一次,它会生成ClassCastException.documentation说getInt()“如果此名称的首选项不是int,则抛出ClassCastException。”-我知道此首选项已明确定义为(字符串?)但是,如果这是异常的原因,我应该如何使用SharedPreferences.getInt()?我知道我可以使用Shared

android - 如何声明 Android 偏好的类型?

我有一个看起来像这样的preferences.xml:当我执行sp.getString("sample","3.0")时,它工作正常并返回一个字符串,但它不应该是一个字符串,它应该是一个float。运行sp.getFloat("sample",3.0f)会抛出ClassCastException,因为它是一个字符串。我应该在XML中添加什么以便将首选项存储为float? 最佳答案 在您的首选项xml中,您可以添加一个选项android:numeric,其值为"integer"。这样用户应该只能输入一个有效的整数值。加载设置时,您应该

android - 如何声明 Android 偏好的类型?

我有一个看起来像这样的preferences.xml:当我执行sp.getString("sample","3.0")时,它工作正常并返回一个字符串,但它不应该是一个字符串,它应该是一个float。运行sp.getFloat("sample",3.0f)会抛出ClassCastException,因为它是一个字符串。我应该在XML中添加什么以便将首选项存储为float? 最佳答案 在您的首选项xml中,您可以添加一个选项android:numeric,其值为"integer"。这样用户应该只能输入一个有效的整数值。加载设置时,您应该