我需要以编程方式使用GPS获取当前位置.我怎样才能实现它?
我正在使用Web视图,我在其中添加图像视图.如何将此图像视图的背景设置为透明?
我试过这个:
mImageview.setBackgroundResource(R.color.trans);
Run Code Online (Sandbox Code Playgroud)
哪里trans→ <color name="trans">#00000000 </color>.
我正在创建一个文件作为电子邮件的附件发送.现在我想在发送电子邮件后删除图像.有没有办法删除文件?
我试过myFile.delete();但它没有删除该文件.
我正在使用Android的这个代码,因此编程语言是使用通常的Android方式访问SD卡的Java.当我在发送电子邮件后返回到屏幕onActivityResult时,我正在删除该方法中的文件Intent.
我正在使用TableLayout.我需要为此布局同时进行水平和垂直滚动.默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用.
我使用的是Android SDK 1.5 r3.我已经尝试过了android:scrollbars="horizontal".
我在一些论坛上看到,在杯形蛋糕更新中,水平滚动是可能的.
如何让我的布局在两个方向上滚动?
我想在我的应用程序中使用外部字体.我尝试添加新的fonts使用,AssetManager但它没有用.以下是我的代码:
Typeface face;
face = Typeface.createFromAsset(getAssets(), "font.otf");
textview.setTypeface(face);
Run Code Online (Sandbox Code Playgroud)
但它没有显示文字......
请帮我解决一下这个.
单击标记时,摄像机的默认行为是将其置于屏幕中心,但由于我通常在信息窗口中有长文本描述,因此实际更改摄像机位置以使标记位于底部时更方便屏幕(使信息窗口位于屏幕中央).我想我应该能够通过覆盖onMarkerClick函数来做到这一点(当此函数返回true时,默认行为被取消)
@Override
public boolean onMarkerClick(final Marker marker) {
// Google sample code comment : We return false to indicate that we have not
// consumed the event and that we wish
// for the default behavior to occur (which is for the camera to move
// such that the
// marker is centered and for the marker's info window to open, if it
// has one).
marker.showInfoWindow();
CameraUpdate center=
CameraUpdateFactory.newLatLng(new LatLng(XXXX,
XXXX));
mMap.moveCamera(center);//my question is how to get this center …Run Code Online (Sandbox Code Playgroud) 我需要接收网络连接的广播,如网络连接,断开连接等.我正在使用广播接收器.任何人都可以告诉我我需要捕获哪些针对网络事件的意图行动,现在根据我在互联网上的搜索,我使用的是android.net.ConnectivityManager.CONNECTIVITY_ACTION.
这是我的广播接收器类:
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class NetworkStateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(
android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
// do something..
}
}
}
Run Code Online (Sandbox Code Playgroud)
我还添加了访问网络状态的权限:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Run Code Online (Sandbox Code Playgroud)
这是我在清单文件中声明此类的方法
<receiver class=".NetworkStateReceiver" android:name=".NetworkStateReceiver">
<intent-filter>
<action android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
如果我错了或者有任何其他方式来捕获网络事件,请建议我正确的意图行动.
我想将Twitter集成到我的Android应用程序中,以便我可以将消息发布到Twitter.
我想在我的Android应用程序上实现bonjour/zero conf.我正在使用jmDns库来搜索所有可用的设备.以下是我用于搜索同一网络中的设备的代码:
public class ListDevices extends ListActivity {
JmDNS jmdns;
JmDNSImpl impl;
MulticastLock lock;
protected ServiceListener listener;
protected ServiceInfo info;
public ListView lv;
public ArrayList<String> deviceList;
public int cancel = 0;
public final static String TAG = "ListDevices";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
deviceList = new ArrayList<String>();
showAllPrinters();
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, deviceList));
lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long …Run Code Online (Sandbox Code Playgroud) 我想在我的strings.xml文件中创建以下字符串数组:
<string-array name="an_array_columns">
<item>% Select percentage1</item>
<item>% Select percentage2</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)
这里的字符串是"%select percentage".现在,当我在strings.xml中写这个时,我收到以下错误:
Multiple annotations found at this line:
- error: Multiple substitutions specified in non-positional format; did you mean to
add the formatted="false" attribute?
- error: Found tag </item> where </string-array> is expected
Run Code Online (Sandbox Code Playgroud)
我知道我们可以改变&到&或'到\'的,但我该怎么为百分号吗?
android ×10
android-maps ×1
bonjour ×1
fonts ×1
geolocation ×1
google-maps ×1
gps ×1
intentfilter ×1
jmdns ×1
location ×1
twitter ×1
zeroconf ×1