小编mud*_*dit的帖子

如何在Android中以编程方式获取当前GPS位置?

我需要以编程方式使用GPS获取当前位置.我怎样才能实现它?

gps android location geolocation

694
推荐指数
17
解决办法
86万
查看次数

在Android上设置imageview的透明背景

我正在使用Web视图,我在其中添加图像视图.如何将此图像视图的背景设置为透明?

我试过这个:

mImageview.setBackgroundResource(R.color.trans);
Run Code Online (Sandbox Code Playgroud)

哪里trans<color name="trans">#00000000 </color>.

android android-widget

309
推荐指数
16
解决办法
67万
查看次数

如何从SD卡中删除文件?

我正在创建一个文件作为电子邮件的附件发送.现在我想在发送电子邮件后删除图像.有没有办法删除文件?

我试过myFile.delete();但它没有删除该文件.


我正在使用Android的这个代码,因此编程语言是使用通常的Android方式访问SD卡的Java.当我在发送电子邮件后返回到屏幕onActivityResult时,我正在删除该方法中的文件Intent.

android android-sdcard

129
推荐指数
7
解决办法
22万
查看次数

如何使我的布局水平和垂直滚动?

我正在使用TableLayout.我需要为此布局同时进行水平和垂直滚动.默认情况下,我可以在视图中进行垂直滚动,但水平滚动不起作用.

我使用的是Android SDK 1.5 r3.我已经尝试过了android:scrollbars="horizontal".

我在一些论坛上看到,在杯形蛋糕更新中,水平滚动是可能的.

如何让我的布局在两个方向上滚动?

android android-widget android-scrollview

61
推荐指数
2
解决办法
10万
查看次数

在android中使用外部字体

我想在我的应用程序中使用外部字体.我尝试添加新的fonts使用,AssetManager但它没有用.以下是我的代码:

Typeface face;

face = Typeface.createFromAsset(getAssets(), "font.otf");

textview.setTypeface(face);
Run Code Online (Sandbox Code Playgroud)

但它没有显示文字......

请帮我解决一下这个.

fonts android android-widget

60
推荐指数
3
解决办法
8万
查看次数

如何使相机居中,使标记位于屏幕的底部?(谷歌地图api V2 Android)

单击标记时,摄像机的默认行为是将其置于屏幕中心,但由于我通常在信息窗口中有长文本描述,因此实际更改摄像机位置以使标记位于底部时更方便屏幕(使信息窗口位于屏幕中央).我想我应该能够通过覆盖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 google-maps android-maps

43
推荐指数
4
解决办法
3万
查看次数

android sdk中网络事件的意图动作

我需要接收网络连接的广播,如网络连接,断开连接等.我正在使用广播接收器.任何人都可以告诉我我需要捕获哪些针对网络事件的意图行动,现在根据我在互联网上的搜索,我使用的是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)

如果我错了或者有任何其他方式来捕获网络事件,请建议我正确的意图行动.

android intentfilter android-networking

38
推荐指数
2
解决办法
4万
查看次数

Android应用程序上的twitter集成

我想将Twitter集成到我的Android应用程序中,以便我可以将消息发布到Twitter.

twitter android

34
推荐指数
2
解决办法
4万
查看次数

Android上的Bonjour实现

我想在我的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)

android bonjour zeroconf jmdns

29
推荐指数
2
解决办法
3万
查看次数

在android的strings.xml中写%

我想在我的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)

我知道我们可以改变&&amp;'\'的,但我该怎么为百分号吗?

android

28
推荐指数
2
解决办法
3万
查看次数