Tag: java的

从另一个类调用动态按钮

我是java / Android的新手,我想传递我定义了我的按钮属性的方法。 并且该方法是在另一个不能实现Activity的类中编写的。 ex class ViewProvider extends xyz { public Button getButton(){ Button one=new Button(); one.setText(“abc”); one.setTypeface(Typeface.DEFAULT_BOLD); //and other properties like color,Gravity ect return one } } Class calcu extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_list); ViewProvider v=new ViewProvider(); RelativeLayout relativelayout = new RelativeLayout(this); relativelayout.addView(v.getButton); setContentView(relativelayout); } 但我得到一个错误

java中的集合,子集和回文

如何检查列表是否是java中另一个列表的子集? 如果给定列表是回文列表,如何使用两个ListIterators检查以返回true。

Android:进度条将对象上传到服务器

我想在将对象发送到服务器时放入进度条。 但我不知道我需要在doInBackground()方法中编写什么代码以及onProgressUpdate()中的代码。 这里Client Socket程序用于将Object发送到服务器。 代码(内部类): class DownloadFileAsync extends AsyncTask { @Override protected void onPreExecute() { dialog = new ProgressDialog(this); dialog.setMessage(“Uploading…”); dialog.setIndeterminate(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.show(); } @Override protected String doInBackground(String… aurl) { } @Override protected void onProgressUpdate(String… progress) { } @Override protected void onPostExecute(String unused) { } } 所以,这里我需要在doInBackground()和onProgressUpdate()中编写 我有一个对象serverObject ,我需要将其发送到服务器。 目前我正在使用以下代码将对象发送到服务器而没有任何进度条: Socket s = new […]

自定义HTTP方法在Retrofit 2中不起作用

您好我在我的代码中使用了自定义方法,如下所示,但它总是给我 java.lang.IllegalArgumentException:方法AUTH必须没有请求体。 我的代码不工作总是说: Custom method AUTH, must not have a Body @Headers(“Content-Type: application/json”) @HTTP(method = “AUTH”, path = “login/{deviceId}”, hasBody = true) Call getLogin( @Path(“deviceId”) int deviceId, @Body RequestBody password); 我正在使用以下依赖。 compile ‘com.google.code.gson:gson:2.8.1’ compile ‘com.squareup.retrofit2:retrofit:2.3.0’ compile ‘com.squareup.retrofit2:converter-gson:2.3.0’ compile ‘com.squareup.okhttp3:okhttp:3.8.1’ compile ‘com.squareup.okhttp3:logging-interceptor:3.4.1’ 你能帮我么。

AzureMobileService:将数据插入到表中会产生exception

我是新手来实施Azure移动服务。 我参考了Azure提供的ToDoItem演示。 以同样的方式,我已经为我自己的应用程序创建类User。 然后我将数据插入到MobileServiceTable中,但它给出了如下错误: {“message”:”The operation failed with the following error: ‘A null store-generated value was returned for a non-nullable member ‘CreatedAt’ of type ‘CrazyLabApp.Models.User’.’.”} 我没有创建任何这样的字段,因为它不是在ToDoItem演示中创建的。 我已经看到MobileServiceTable创建了4个默认字段。 createdAt是其中一个领域。 我很想知道我做错了什么。 检查我的以下用户类: public class User { @com.google.gson.annotations.SerializedName(“id”) private String ServiceUserId; @com.google.gson.annotations.SerializedName(“email”) private String Email; @com.google.gson.annotations.SerializedName(“firstname”) private String FirstName; @com.google.gson.annotations.SerializedName(“lastname”) private String LastName; @com.google.gson.annotations.SerializedName(“profilepic”) private String ProfilePic; @com.google.gson.annotations.SerializedName(“introduction”) […]

AsyncTask(异步进程)

我有关于异步任务的问题 来自android的Async 使用2个活动“A”和“B” 通过输入一个单词从URL搜索并在DTO中存储值,然后从getter和setter中获取值。 我的复杂性是我在我的活动“B”中实现了异步,并且该活动从同一个DTO获取值。 问题是,我的post知道在后台做的事情已经从DTO和DTO取得价值从互联网上取得价值……如果互联网连接速度慢的话。 我将意图从“A”发送到“B”并在“B”上显示结果 问题: 1.如果我删除异步,则应用程序显示黑页并冻结(仅在连接速度较慢的情况下)但显示数据 2.如果我使用aync,那么有时会显示进度对话框很长时间,并且知道数据已经在UI中显示 代码链接https://www.dropbox.com/s/p27rpokz68sryv3/SearchData.java https://www.dropbox.com/s/rm3i52djiay327u/SearchData_DTO.java https://www.dropbox.com/s/2hpufx2a12480on/Search.java 请建议我可能的解决方案 问候

如何创建简单的Web服务

如何使用java创建可由移动应用程序(Android / iPhone应用程序)使用的简单Web服务。 请提出解决方案。

R.java在做Android教程时没有生成?

所以我正在研究android.com提供的Android教程。 但是,当我到达添加操作按钮部分时,我尝试使用支持Android 2.1的代码和支持库,这似乎导致.xml文件中的错误。 我有相同的.xml名称,“main_activity_actions.xml”具有相同的确切代码。 我记得我的R.java然后,每当我拿出时都能生成 所以,我不确定这有什么问题。 到目前为止,我的代码在整个教程中基本相同。 教程链接: http : //developer.android.com/training/basics/actionbar/adding-buttons.html 整个代码:

关于计算不同键的总数

我有一个地图存储脚本编号和患者ID在地图中脚本编号是关键正弦它始终是唯一的,如下所示 Map m = new LinkedHashMap(); m.put (“123”, “23”); m.put (“323”, “23”); m.put (“153”, “23”); m.put (“623”, “23”); m.put (“125”, “23”); m.put (“122”, “24”); m.put (“167”, “24”); m.put (“173”, “24”); m.put (“113”, “25”); 现在我的疑问是我需要找出与患者Id 23相关的脚本数量 我们可以看到上面共有5个不同的脚本,患者ID为23,所以我需要计算总数不同的脚本和脚本编号也与患者Id 23相关联,即123,323,153,623,125 我已将值显示为示例,但在我的情况下,动态值将填充到Map中,因此请提供建议。

获取特定像素的x,y位置

我遇到了一个问题,我得到了一个代码,它读取所有像素并获取像素的RGB颜色。 但在此之前,我将图片切成块,这样我也可以计算出更大的图像,而不会超出内存。 这是代码: Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); try { decoder_image = BitmapRegionDecoder.newInstance(filePath, false); } catch (IOException e) { e.printStackTrace(); } try { boolean bool_pixel = true; final int width = decoder_image.getWidth(); final int height = decoder_image.getHeight(); // Divide the bitmap into 1100×1100 sized chunks and process it. // This makes sure that the app will not be “overloaded” […]