寻求解决方案无一例外(Looking for solution without exception)
我的代码中有一段我不喜欢的段落。
imageView=null; textView=null; try{ imageView = (ImageView) convertView; }catch (Exception e){ textView = (TextView) convertView; }
我必须动态决定convertView是ImageView还是TextView。 我的代码工作正常,但如前所述,我不喜欢他。 还有另外一个为什么要处理这个?
I have a little passage in my code I do not like.
imageView=null; textView=null; try{ imageView = (ImageView) convertView; }catch (Exception e){ textView = (TextView) convertView; }
I have to dynamically decide if convertView is an ImageView or an TextView. My code is working fine, but as said before, I don't like him. Is there another why to handle this?
原文:https://stackoverflow.com/questions/29143176
更新时间:2024-05-22 22:05
最满意答案
如果使用此代码,您的代码可能有效
String val=(String) getCellValue(row.getCell(5)); if(!(StringUtils.isEmpty(val))) { blah,blah,blah....!!! }
may your code works if use this code
String val=(String) getCellValue(row.getCell(5)); if(!(StringUtils.isEmpty(val))) { blah,blah,blah....!!! }
相关问答
更多-
这听起来像你正在使用关系数据库(例如MySQL,Postgres等),它使用固定的列表。 您应该使用基于文档的数据库(例如CouchDB,Mongo等)。 这将是最好的解决方案。 但是,如果您使用关系数据库卡住,则可以使用EAV模型 。 这是一个基本的例子: 为实体(excel文件)创建一个表:EntityID,ExcelFileName 为属性(列信息)创建一个表:AttributeID,EntityID,AttributeName 为值(excel行/列)创建一个表:ValueID,RowNumber, ...
-
Java SQLite数据库,插入条目给出nullPointerException(Java SQLite database, insert entry giving nullPointerException)[2023-07-15]
你有一个小错误,只是你创建了两个不同的PreparedStatement对象所以改变 PreparedStatement stmt = c.prepareStatement(query); 至 pstmt = c.prepareStatement(query); You have small mistake just you have created two different PreparedStatement object So change PreparedStatement stmt = c.pre ... -
要使文件上传工作,需要记住一些事项。 首先,您提交的表单需要具有enctype="multipart/form-data" 。 否则PHP无法识别该文件。 执行此操作后,未定义的索引警告将消失。 其次,您需要将上传的文件从PHP上传到的临时目录中移动到您可以访问该文件的目录中。 使用move_uploaded_file()执行此任务(有关示例,请参阅PHP文档)。 然后,您可以使用您将其移入的目录及其名称来访问该文件。 To get the file upload working there are a f ...
-
如何使用php一次性将多组图像上传到数据库(How to upload a multiple set of images to database at once using php)[2022-07-04]
我们只将图像或文件的路径存储到数据库中。 所以你已经上传将你的图片全部传送到每行的csv中。 首先你必须在你的服务器上传图像,然后采取这个路径并将其存储在数据库中。 或者如果图像已经在服务器上。 你可以直接保存他们的路径。 $handle = fopen($_FILES['filename']['tmp_name'], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $data1 = data[0]; $data2 = ... -
我按照@bendataclear的建议: “就我个人而言,我只需导入一个临时表,然后编写INSERT INTO X SELECT查询以移动到正确的列中。” I followed the suggestion of @bendataclear: "Personally I would just import into a temporary table then write INSERT INTO X SELECT queries to move in the correct columns."
-
MyTask创建了一个“MainActivity”的新实例 - 其中“myDBAdapter”未初始化。 您需要重新初始化或移动它。 您可能应该移动它,因为您可能不希望引用在后台线程上实例化的活动。 MyTask creates a new instance of "MainActivity" - where "myDBAdapter" is not initialized. You need to re-initialize it or move it. You should probably move ...
-
1)你不打开数据库,你可能忘记了在某个地方打开电话 public DbAdapter(Context ctx) { this.mCtx = ctx; open(); } 2)你没有映射值(你应该使用相同的类适配器) SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, mCursor, new String[] {"phrase"}, new int[ ...
-
简单数据库插入Squeryl NullPointerException?(Squeryl NullPointerException on simple database Insert?)[2023-10-25]
这个很容易解决,我有点惊讶我在编译期间没有打嗝。 在组装我的Member类时,我在第三个值上使用了Scala None而不是null ,并且它运行得很好。 太糟糕Squeryl无法为调试提出更好的错误。 This one was an easy fix, and I'm a little surprised I didn't get a hiccup during compile. When assembling my Member class I used Scala None instead of nu ... -
如果使用此代码,您的代码可能有效 String val=(String) getCellValue(row.getCell(5)); if(!(StringUtils.isEmpty(val))) { blah,blah,blah....!!! } may your code works if use this code String val=(String) getCellValue(row.getCell(5)); if(!(StringUtils.isE ...
-
编辑:似乎你想从数据库中检索一行。 您应该使用MyObject而不是List
来实现您想要的。 以下是MyObject的示例,请参阅POJO public class MyObject { String name = "", stats = ""; Long period = 0, frequency = 0, receivingtime = 0; // empty constructor public MyObject() { } // s ...