我上周一直在玩Honeycomb,并且很难在Action Bar中找到关于多个下拉列表的内容.我已经使用了本教程并成功添加了一个下拉列表.但我不知道如何添加另一个.如果你知道怎么做,请告诉我.谢谢.
PS还有一点我怎么能改变Action Bar中元素的位置(这是偏离主题的)?
java android android-widget android-3.0-honeycomb android-actionbar
在Honeycomb(Android 3.0)上运行的设备上使用AutoCompleteTextView组件(使用Motorola Xoom进行测试)时,我遇到了一个奇怪的问题.我使用以下堆栈跟踪得到Nullpointer异常:
致命异常:在android.widget.PopupWindow.getMaxAvailableHeight(PopupWindow.java:1152)在android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1054)在android.widget.ListPopupWindow.show(ListPopupWindow主显示java.lang.NullPointerException. java:516)在android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1047)的android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:931)在android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:914)at android.widget.Filter $ ResultsHandler.handleMessage(Filter.java:285)在android.os.Handler.dispatchMessage(Handler.java:99)在android.os.Looper.loop(Looper.java:126)在android.app .ActivityThread.main(ActivityThread.java:3997)在java.lang.reflect.Method.invokeNative(本机方法)在java.lang.reflect.Method.invoke(Method.java:491)在com.android.internal.os .ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841)at com.android.internal.os.ZygoteInit.main(Zyg oteInit.java:599)at dalvik.system.NativeStart.main(Native Method)
请注意,我不会在包括Gingerbread在内的任何其他Android版本上获得此异常.它很难调试,因为我没有Honeycomb代码库的原始源代码.如果有人能帮助我,我将不胜感激.
谢谢,托里.
我有...
entity = simplejson.dumps({"a":unicode(datetime.datetime.utcnow())})
Run Code Online (Sandbox Code Playgroud)
如何将日期时间(转换为unicode)再次转换回日期时间?
所以我可以做点什么......
entity2 = simplejson.loads(entity)
#your answer here..
add5 = entity2["a"] + datetime.timedelta(minutes=5)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我是json解析的新手,我从请求中抓取了一个json字符串,现在我需要用java解析它.我正在使用json-lib.但我真的被困住了,因为我不熟悉它.我需要提取以下数据
1. name (hotel name)
2. starRating
3. geoPoint
Run Code Online (Sandbox Code Playgroud)
我使用了以下java代码,但它没有给我我需要的结果,请有人帮助我...
非常感谢!
java代码(s是我得到的json字符串)
JSONObject json = (JSONObject) JSONSerializer.toJSON(s);
JSONArray jarray = json.getJSONArray("hotels");
for(int i=0 ; i < jarray.size(); i++) {
System.out.println("jarray [" + i + "] --------" + jarray.getString(i));
}
Run Code Online (Sandbox Code Playgroud)
json我需要解析
[
{
"total": 250,
"offset": 0,
"requestID": "-btygi09oxfov",
"locationName": "Paris, France",
"locationLatitude": 48.86,
"locationLongitude": 2.34,
"cityCode": "PARIS_J_FR",
"hotels": [
{
"ypid": "YN10001x300073304",
"id": 56263,
"hotelRateIndicator": "2",
"name": "Renaissance Paris Vendome Hotel",
"brandCode": "69",
"addressLine1": "4 Rue du Mont-Thabor",
"city": "Paris", …Run Code Online (Sandbox Code Playgroud) 如果有人可以帮助我解析这个json结果,那会有可能吗?我已将结果检索为字符串
{"query":{"latitude":39.9889,"longitude":-82.8118},"timestamp":1310252291.861,"address":{"geometry":{"coordinates":[-82.81168367358264,39.9887910986731],"type":"Point"},"properties":{"address":"284 Macdougal Ln","distance":"0.02","postcode":"43004","city":"Columbus","county":"Franklin","province":"OH","country":"US"},"type":"Feature"}}
Run Code Online (Sandbox Code Playgroud) 我正在使用Gson,我有一个对象,其中一个字段是Class
class A {
…
private Class aClass;
… }
Run Code Online (Sandbox Code Playgroud)
当我使用默认的Gson对象将实例解析为Json时,aClass变为空.
知道为什么吗?
嘿,我正在尝试在我的Android应用程序上实现一项服务.服务必须执行活动的相同任务.IE,如果在CallLog.Calls内容提供程序上发生某些更改,则必须通知服务并将数据插入数据库,即使应用程序未运行,我的意思是,服务将在应用程序启动后运行,因此如果应用程序被杀死,服务将继续运行,直到操作系统停止它,对吧?
因此它将在后台运行,收集CallLog.Calls服务上更改的所有数据.但是,该服务没有运行.我在Activity的onCreate()方法中加注它.在Service中,我实现了一个ContentObserver类,它使用onChange()方法,以防CallLog.Calls内容提供程序中的某些更改.
我不知道的是为什么服务没有启动,以及为什么即使我在DDMS视角杀死应用程序它也不起作用.
这是代码.
该Activity名为RatedCalls.java
public class RatedCalls extends ListActivity {
private static final String LOG_TAG = "RATEDCALLSOBSERVER";
private Handler handler = new Handler();
private SQLiteDatabase db;
private CallDataHelper cdh;
StringBuilder sb = new StringBuilder();
OpenHelper openHelper = new OpenHelper(RatedCalls.this);
private Integer contentProviderLastSize;
private Integer contentProviderCurrentSize;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
cdh = new CallDataHelper(this);
db = openHelper.getWritableDatabase();
startService(new Intent(this, RatedCallsService.class));
registerContentObservers();
Log.i("FILLLIST", "calling from onCreate()");
Cursor cursor = getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
android.provider.CallLog.Calls.DATE + " …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我目前仅支持某些活动的纵向方向,因为我认为大多数手机用户大多数时间都会使用纵向(并用一只手握住设备).
然而,在新的Honeycomb平板电脑上,用户似乎可能更频繁地使用横向,所以我想支持更多我的活动的两种方向.
我宁愿不必回去为较小的屏幕尺寸添加横向布局(一直到QVGA),所以我想知道是否有一种方法只支持xlarge屏幕类型的景观,但不是其他.
我目前正在进入Android 3.0预览版的片段API,并构建了以下最小编码:
我有一个Activty,它将嵌入Fragment(s),目前实现如下:
public class Cockpit extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cockpit);
}
public static class InfoFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
ViewGroup infoFragmentRoot = (ViewGroup) getActivity().findViewById(
R.id.infoFragmentRoot) ;
return inflater.inflate(R.id.infoFragment, container, false);
}
}
Run Code Online (Sandbox Code Playgroud)
}
活动的相应布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<fragment android:name="test.android.ui.cockpit.Cockpit$InfoFragment"
android:id="@+id/infoFragment"
android:layout_weight="1"
android:layout_width="10dp"
android:layout_height="match_parent" >
<LinearLayout …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的Android应用程序上进行facebook集成.
我的要求是在每个新闻源到来时阅读它们,并使用toast显示它.
我在网上看到的所有示例应用程序都基于Web GUI.任何人都可以帮我提供示例代码或提示,以便在我的应用程序中将更新读入变量/字符串中吗?
此致,Dhanesh