Tag: android

RelativeLayout中的百分比宽度

我正在为我的Android应用程序中的登录Activity工作。 下面的图片是我想让它看起来像: 我能用下面的XML实现这个布局。 问题是,这有点冒险。 我不得不为主机EditText硬编码一个宽度。 具体来说,我不得不指定: android:layout_width="172dp" 我真的想给主机和端口EditText的百分比宽度。 (主机80%,端口20%)这可能吗? 下面的XML适用于我的Droid,但它似乎并不适用于所有屏幕。 我真的很喜欢一个更强大的解决方案。 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/host_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/home" android:paddingLeft="15dp" android:paddingTop="0dp" android:text="host" android:textColor="#a5d4e2" android:textSize="25sp" android:textStyle="normal" /> <TextView android:id="@+id/port_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/home" android:layout_toRightOf="@+id/host_input" android:paddingTop="0dp" android:text="port" android:textColor="#a5d4e2" android:textSize="25sp" android:textStyle="normal" /> <EditText android:id="@+id/host_input" android:layout_width="172dp" android:layout_height="wrap_content" android:layout_below="@id/host_label" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_marginTop="4dp" android:background="@android:drawable/editbox_background" android:inputType="textEmailAddress" /> <EditText android:id="@+id/port_input" android:layout_width="100dp" […]

Android getResources()。getDrawable()弃用API 22

使用新的android API 22 getResources().getDrawable()现在已被弃用。 现在最好的方法是只使用getDrawable() 。 什么改变?

为什么LayoutInflater会忽略我指定的layout_width和layout_height布局参数?

我已经遇到了严重的麻烦让LayoutInflater按预期工作,其他人也如此: 如何使用layoutinflator在运行时添加视图? 。 为什么LayoutInflater忽略我指定的布局参数? 例如,为什么我的资源XML中的layout_width和layout_height值不符合要求?

Restful API服务

我正在寻找一个服务,我可以用它来调用基于Web的REST API。 基本上我想开始一个应用程序初始化服务,然后我想能够要求该服务请求一个网址,并返回结果。 在此期间,我希望能够显示一个进度窗口或类似的东西。 我已经创建了一个使用IDL的服务,我已经在某个地方读过你只需要交叉应用程序通信的地方,所以认为这些需求是剥离出来的,但是不知道如何在没有它的情况下做回调。 另外,当我点击post(Config.getURL("login"), values) ,应用程序似乎暂停了一段时间(似乎很奇怪 – 认为服务背后的想法是,它运行在不同的线程! 目前我有一个服务后,得到HTTP方法里面,几个AIDL文件(双向通信),一个ServiceManager,处理启动,停止,绑定等服务,我动态创建一个处理程序与特定的代码根据需要进行回调。 我不希望任何人给我一个完整的代码库来处理,但一些指针将不胜感激。 代码(大部分)全部: public class RestfulAPIService extends Service { final RemoteCallbackList<IRemoteServiceCallback> mCallbacks = new RemoteCallbackList<IRemoteServiceCallback>(); public void onStart(Intent intent, int startId) { super.onStart(intent, startId); } public IBinder onBind(Intent intent) { return binder; } public void onCreate() { super.onCreate(); } public void onDestroy() { super.onDestroy(); mCallbacks.kill(); […]

我可以在其他课程中创建活动的对象吗?

我已经在mainactivity中定义了一个函数,现在我想要访问我的app中的另一个类。我已经创建了一个mainactivity的对象,通过使用该对象我已经调用了函数。它不显示任何错误,但它不会执行每一次尝试执行应用程序崩溃? 任何解决方案

Android – 短信广播接收器

我一直试图让这个程序工作,但迄今没有运气。 我无法找到我在做错的地方。 我不确定代码是否有问题,或调试。 如果有新的短信到达,我正在通知您。 这是我的程序: package Technicaljar.SMSBroadcastReceiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.util.Log; public class SMSBroadcastReceiver extends BroadcastReceiver { private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED"; private static final String TAG = "SMSBroadcastReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.i(TAG, "Intent recieved: " + intent.getAction()); if (intent.getAction() […]

在Android中下标和上标字符串

你怎么能打印一个下标或上标字符串? 你可以做这个没有外部库吗? 我希望这显示在Android中的TextView 。

自定义ListView适配器与Android筛选器

请尝试在我的列表视图上实现一个过滤器。 但是,每当文本更改,列表消失。请帮助这里是我的代码。 适配器类。 package com.talagbe.schymn; import java.util.ArrayList; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; public class HymnsAdapter extends ArrayAdapter<Hymns> { ArrayList<Hymns> hymnarray; Context context; LayoutInflater inflater; int Resource; public HymnsAdapter(Context context, int resource, ArrayList<Hymns> objects) { super(context, resource, objects); // TODO Auto-generated constructor stub hymnarray=objects; Resource= resource; this.context=context; inflater= (LayoutInflater) […]

Android软键盘覆盖edittext字段

有没有办法让屏幕滚动,让文本字段被看到?

getDefaultSharedPreferences和getSharedPreferences之间的区别

Android中的getDefaultSharedPreferences和getSharedPreferences什么区别? 谁能解释一下吗?