Tag: android

我的标签小部件不显示图片图标

我正在尝试设置应用程序,我很满意我的进度。 我已经设置了一个标签小部件,如下所示,它工作正常,但我设置的图片没有显示。 这似乎让我感到困惑![在此输入图像描述] [1]所有正确的代码。 任何评论都将大大恢复:) 所以要审查我试图在每个标签下面放置图标,例如collections夹下的星星和警报下的时钟等… TrainMain.java package com.tris.trainbuzzer; import android.app.TabActivity; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.widget.TabHost; import android.widget.TabHost.TabSpec; @SuppressWarnings({ “deprecation” }) public class TrainMain extends TabActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_train_main); Resources res = getResources(); TabHost tabHost = getTabHost(); […]

如何在ormlite中保存带有“外来对象”的对象

这是我的数据库: CREATE TABLE other ( id integer primary key autoincrement not null, texto text ); CREATE TABLE tabela (campoid INTEGER primary key autoincrement not null, camponome text not null, chave int, foreign key (chave) references other(id)); 这是我的课程: @DatabaseTable(tableName = “tabela”) public class Bean { @DatabaseField(columnName = “campoid”, generatedId = true) private int _id; @DatabaseField(columnName = […]

上传图像为base64格式和压缩图像,然后通过改造发送到服务器?

我已经制作了上传图片,我在互联网上的教程中进行了改造。 这是我的代码: AcademicClient.class @Multipart @POST(“/”) Call postImage(@Part MultipartBody.Part image, @Part(“name”)RequestBody name); MainFeed.class File file = new File(filePath); RequestBody reqFile = RequestBody.create(MediaType.parse(“image/*”),file); MultipartBody.Part body = MultipartBody.Part.createFormData(“upload”,file.getName(),reqFile); RequestBody name = RequestBody.create(MediaType.parse(“text/plain”),”upload_test”); Log.d(“xxxxxxx”,body + ” —- “+ name); AcademicClient client = ServiceGenerator.createService(AcademicClient.class); Call call = client.postImage(body,name); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { } […]

Jsoup – CSS查询选择器问题(?)

我有一个奇怪的问题,我一直在使用Jsoup 1.7.2 ,没有问题,只有现在,当我尝试从这个网站检索主要标题: www.jornaldamarinha.pt ,使用此代码: // Connecting… Document doc = Jsoup.connect(“http://www.jornaldamarinha.pt”) .timeout(0) .get(); // “*[class*=zincontent-wrap]” in “Jsoup idiom”, means: // Select all tags that contains classes with “zincontent-wrap” on its name. Elements elems = doc.select(“*[class*=zincontent-wrap]”); // Retrieves 0 results! int t = elems.size(); Log.w(“INFO”, “Total Headlines: ” + t); // Loop trought all retrieved headlines: […]

OpenGL es 1.1 – android – 做gl.glDeleteTextures免费video内存吗?

语境: 我使用gl.glGenTextures将2个纹理加载到大小为2的int []中,然后将纹理绑定到int []的每个槽。 (这很好用,我可以将每个纹理绘制到我准备的“纹理方块”) 现在,我的实际关注点: 运行gl.glDeleteTextures(2,包含2个纹理指针的int [],0)是否清除了生成到我的int []中的2个纹理所使用的内存? 或者这只是释放“纹理名称”?

android – 获取位置并仅在条件为真时将数据发送到远程服务器

我正在构建一个需要将用户位置发送到远程服务器的应用程序(在本例中为Pusher)。 目标是近乎实时地更新他们在地图上的位置,但仅限于他们在工作时,否则应用程序将不需要跟踪他们的位置。 如果他们离开他们接受工作的活动(因此被放置在地图上)并且他们完全离开应用程序,我需要位置更新保持活动状态。 一旦他们到达目的地,我希望停止此背景跟踪。 我一直在关注Android的Service组件,但我不确定它是否是我需要的。 更新应无限期地在后台进行,但仅在用户被分配到作业时(更新在他们接受作业时开始,在到达目的地时结束)。 Bound服务会是最好的吗? 如果是这样,那么与此问题相关的一些代码将非常受欢迎,因为我能找到的很多内容都是通用的,并且可以返回随机整数。 这是我希望在后台执行的代码: package com.example.locationtester; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.TextView; import android.widget.Toast; import com.pusher.client.Pusher; import com.pusher.client.PusherOptions; import com.pusher.client.channel.PrivateChannel; import com.pusher.client.channel.PrivateChannelEventListener; import com.pusher.client.connection.ConnectionEventListener; import com.pusher.client.connection.ConnectionState; import com.pusher.client.connection.ConnectionStateChange; import com.pusher.client.util.HttpAuthorizer; import org.json.JSONException; import org.json.JSONObject; public class MainActivity extends AppCompatActivity { […]

我该如何删除按钮?

我有一个带有我的按钮名称的字符串。 假设它叫做String A String A = myButtonName; 现在,如果我想删除按钮: layout.removeView(myButtonName); 这可行,但是,我不能在字符串上这样做。 我怎么能在我的字符串上做到这一点? 像这样,现在我收到一个错误,因为它是一个字符串: layout.removeView(A); 如何使用与视图对应的字符串删除视图? 从理论上讲,我想将我的字符串强制转换为ViewGroup 简化问题: 我有一个字符串。 该字符串也是我的按钮的变量名称。 我可以使用字符串删除按钮吗?

JSON,XML连接到Android的web api?

我是Android和Java世界的新手,我想知道如何从web api获取数据http://www.imdbapi.com/进入android。 我应该使用JSON还是XML? 步骤是什么? 首先,我想知道如何下载数据,然后如何将其解析为变量。 任何示例代码?

getAdapterPosition在ViewHolder类中返回-1

我正试图在我的ViewHolder类中显示一个AlertDialog ,点击接受按钮后,我从一个项目列表中获取带有getAdapterPosition的Model项目,但在Fabric Crashlytics中我因为ArrayIndexOutOfBoundsException而导致13次崩溃,其中长度为12但是请求的索引是-1,崩溃是针对此部分代码中的getPaymentMode class ViewHolder extends RecyclerView.ViewHolder { TextView time, capacity, description; View button; ImageView avatar; ViewHolder(View v) { super(v); time = v.findViewById(R.id.reserve_times_time); capacity = v.findViewById(R.id.reserve_times_capacity); button = v.findViewById(R.id.button); description = v.findViewById(R.id.reserve_times_description); avatar = v.findViewById(R.id.avatar); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setView(R.layout.layout_dialog); alertDialogBuilder.setPositiveButton(“accept”, null); alertDialogBuilder.setNegativeButton(“cancel”, null); final […]

如何在使用json的android中使用post方法

我使用json创建了一个Android应用程序,用于从ror网站获取并在listview中显示,现在我想从我们的应用程序添加数据,它必须在我们的应用程序中显示在列表视图中,然后它也必须在网站中显示。如何在我们的应用程序中使用post方法和显示。 得到我喜欢的方法 public class MainActivity extends ListActivity implements FetchDataListener { private ProgressDialog dialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_list_item); initView(); } private void initView() { // show progress dialog dialog = ProgressDialog.show(this, “”, “Loading…”); String url = “http://floating-wildwood-1154.herokuapp.com/posts.json”; FetchDataTask task = new FetchDataTask(this); task.execute(url); } @Override public void onFetchComplete(List data) { // dismiss […]