我搜索并搜索并搜索了这个!
所以我有一个应用程序小部件,它有一个配置活动,我可以在应用程序上按下按钮时打开.场景是:
该应用程序打开了.
使用主页按钮关闭应用程序.
选择添加我的小部件
我已经配置了小部件.
放在我的主屏幕上
然后使用窗口小部件上的按钮再次打开配置活动.
按回来取消新配置将把我带回应用程序.
按下后我想回家.
基本上我要问的是.如何在自己的任务/堆栈中启动配置活动?
我已经调查了意图过滤器,但我只是不太确定,或者它可能与它所在的包有关,或者它可能是不可能的!
我想这可能与我用来启动配置活动的意图有关
Intent configIntent = new Intent(this, Configuration.class);
configIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
remoteView.setOnClickPendingIntent(R.id.config, PendingIntent.getActivity(this, 0, configIntent, PendingIntent.FLAG_UPDATE_CURRENT));
Run Code Online (Sandbox Code Playgroud)
也许是因为我用'this'作为上下文启动它,它总是在我的应用程序堆栈中启动...但是挂起的意图api是:PendingIntent API 1 "注意,活动将在现有活动的上下文之外启动"
所以,是的,我现在就停止说话,因为我最终会进入圈内!
编辑
所以android:launchMode="singleInstance"在清单中尝试过就像所说的那样.这有效但它会阻止'startActivityForResult'行为正常工作.(这是配置活动的全部原因)获取错误:
WARN/ActivityManager(59):活动作为新任务启动,因此取消活动结果.
所以仍然没有找到解决方案.
好的,我已经阅读了And Dev网站上的自定义对话框说明 http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
它显示了如何制作自定义对话框,而不是如何自定义标题!
基本上我的标题太长了,我希望它滚动(如textview)或更好仍然有一个'marquee'效果,我认为它被称为.
或者如果我不能滚动它,给它更多的空间来包裹更多的线条!
任何想法,我不抱太大的希望,因为它不在android.dev :-(
问题是上面提到的错误
我从网上得到的xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Doc>
<Root>
<Record>
<sar_id>1</sar_id>
<sar_region><![CDATA[Antigua & Barbuda]]></sar_region>
<sar_auth>Antigua and Barbuda Defence Force Coast Guards
</sar_auth>
<email>abdfcg@candw.ag</email>
<primary><![CDATA[1 268 462 06 71]]></primary>
<secondary></secondary>
</Record>
<Record>
<sar_id>2</sar_id>
<sar_region><![CDATA[Argentina]]></sar_region>
<sar_auth>Comando de Operaciones Navals, Argentine Navy
</sar_auth>
<email>coopacsm@ara.mil.ar</email>
<primary><![CDATA[54 2932 487 640?]]></primary>
<secondary></secondary>
</Record>
<Record>
<sar_id>3</sar_id>
<sar_region><![CDATA[Aruba]]></sar_region>
<sar_auth>SARFA
</sar_auth>
<email>sarfa16@hotmail.com</email>
<primary><![CDATA[297 5 837371]]></primary>
<secondary></secondary>
</Record>
</Root>
</Doc>
Run Code Online (Sandbox Code Playgroud)
我解析xml的代码
try{
URL url = new URL(
"http://myurl.com");
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxparser = factory.newSAXParser();
XMLReader xmlReader = saxparser.getXMLReader();
SARParser …Run Code Online (Sandbox Code Playgroud) 对,抱歉我想不出谷歌这个正确的话.所以我不得不问.
我有一个long(System.currentTimeMillis())
让我们说
3453646345345345
我想删除最后六位(或其他数字)的数字,我想我可以这样做一些位移?
所以我最终会
3453646345
编辑
我想System.currentTimeMillis()在一个时间框内得到,所以如果我要求时间然后在29秒后再次询问它将返回相同的数字,但如果我问31秒后它将返回不同的数字.30秒的时间盒可配置.
我知道在这个网站上有类似的问题,我已经尝试了一些建议解决方案,其中一些对之前问过这个问题的人有用。但是,我仍然收到两次而不是一次发送相同的数据。
这是代码:
final ProgressDialog progressDialog = DialogsUtils.showProgressDialog(DirectSendActivity.this, getResources().getString(R.string.sending));
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
StringRequest stringRequest = new StringRequest(Request.Method.POST,
direct_send_url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean succcess = jsonResponse.getBoolean("success");
if (succcess) {
onSendSuccess();
progressDialog.dismiss();
} else {
onSendFailed();
progressDialog.dismiss();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
NetworkResponse networkResponse = error.networkResponse;
Log.e(TAG, "Volley error: " …Run Code Online (Sandbox Code Playgroud) 我试图创建一个行布局,其中每个列表项都有一个模板可供使用.目前我有这个,它允许我在每个列表中显示单行文本.
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="20sp"
android:padding="100dp" >
</TextView>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试更改它以允许我添加更多项目(如图像按钮和更多文本字段)时,它始终不允许我编译.
我尝试从developer.android网站上的教程中获取一段xml,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:textSize="16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但是它引发了一个错误说明 - 不允许匹配"[xX] [mM] [lL]"的处理指令目标. - 错误:解析XML时出错:XML或文本声明不在实体的开头
有人可以帮我弄这个吗?我不太清楚这个错误意味着什么.
更新:
我所试图做的是有像右侧的边栏,显示的项目清单,与我张贴,我能够得到我想要的结果,第一个XML片段,但我不能让任何改变.
package com.project.test;
import android.app.ListFragment;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class TestListFragment extends ListFragment {
String [] Items = {"Item A", "Item B", "Item C"};
@Override
public void onActivityCreated(Bundle savedInstanceState) { …Run Code Online (Sandbox Code Playgroud) 当然这应该是有效的Java?我的语法有些错误吗?
return (url != null) ? url : (throw new NotFoundException("No url"));
Run Code Online (Sandbox Code Playgroud)
如果不是,我想我必须这样做:
if(url == null)
throw new NotFoundException("No url");
return url;
Run Code Online (Sandbox Code Playgroud)
谁有更简洁的东西?
当我注释掉视图标签时,应用程序工作正常。当它被包含时它会崩溃。如果有人可以帮助我,我会很高兴。
custom_info_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background_marker"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/distance"
android:textColor="@color/foreground_marker"
android:textSize="14dp"
android:textStyle="bold" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<TextView
android:id="@+id/snippet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/foreground_marker"
android:textSize="14sp" />
<view
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/foreground_marker"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_custom_info_window" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:gravity="center"
android:paddingRight="8dp"
android:text="@string/custom_marker_remove"
android:textColor="@color/foreground_marker"
android:textSize="14sp"
android:textStyle="italic" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
安卓监视器中的错误
12-28 00:28:10.580 22344-22344/com.example.nobodyme.buildingareafinder E/dalvikvm: Could not find class 'com.google.android.chimera.Activity', referenced from method lq.b
12-28 00:28:10.771 22344-22344/com.example.nobodyme.buildingareafinder …Run Code Online (Sandbox Code Playgroud)