小编Ser*_*o76的帖子

仅在没有Jelly Bean的小部件中崩溃setTextViewTextSize

我正在制作一个小部件,您可以在其中指定文本大小

controles.setTextViewTextSize(R.id.LblMsg,TypedValue.COMPLEX_UNIT_SP,textSize);

我正在使用android 4.1

android:minSdkVersion ="8"android:targetSdkVersion ="16"

问题是它在android 4.1中正常工作,但在任何其他版本(ICS,姜饼等)显示强制关闭.

java.lang.NoSuchMethodError:android.widget.RemoteViews.setTextViewTextSize

如果我删除使用"setTextViewTextSize"的代码行,应用程序将完美运行.

我找不到有关此错误原因的信息.

我感谢任何帮助.

问候

android widget remoteview

8
推荐指数
2
解决办法
2526
查看次数

取消注册新的Google云消息传递

我正在使用新的谷歌云消息

(GoogleCloudMessaging gcm =
           GoogleCloudMessaging.getInstance (context);)
Run Code Online (Sandbox Code Playgroud)

我正在关注这个例子,它非常好并且完美地工作:

https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient2

通过这个例子,我可以在GCM中注册,但是我尝试取消注册失败了.

在文档中表明您应该使用以下意图:

com.google.android.c2dm.intent.UNREGISTER
Run Code Online (Sandbox Code Playgroud)

并使用如下:

    

 Intent unregIntent = new Intent ("com.google.android.c2dm.intent.UNREGISTER");
     unregIntent.putExtra ("app", PendingIntent.getBroadcast (this, 0, new Intent (), 0));
     StartService (unregIntent);
Run Code Online (Sandbox Code Playgroud)

不工作......

正如我所说,寄存器工作正常,但不知道如何取消注册.

我必须做的不仅仅是意图吗?我究竟做错了什么?

我感谢任何帮助

感谢致敬

android push-notification google-cloud-messaging

8
推荐指数
1
解决办法
6153
查看次数

Android Make消失或删除地图v2上的蓝点

我正在尝试替换我的应用程序地图上的蓝点.我的意图是,而不是通常的蓝点,显示一个图标形状的平面.我实现了这一点,它完美地运作如下:

//...
GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location location) {
                LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());

 try{
                    myPositionMarker.remove();
                } catch (Exception e){
                 //..
                }

                myPositionMarker = mMap.addMarker(new MarkerOptions()
                        .flat(true)
                        .icon(BitmapDescriptorFactory
                                .fromResource(R.drawable.plane))
                        .anchor(0.5f, 0.5f)
                        .position(
                                new LatLng(location.getLatitude(), location
                                        .getLongitude())));
//...
}
Run Code Online (Sandbox Code Playgroud)

正如我所说,这很好,但现在我看到了我的图标和蓝点:

在此输入图像描述

我已经尝试了很多方法,但找不到任何工作.有许多删除按钮"我的位置"的例子,但我不想删除它.

我想删除蓝点.

在此输入图像描述

我感谢任何帮助.在此先感谢和问候

*更新:

回应@tyczj写的评论我正在删除我的位置按钮,如下所示:

mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(false);
Run Code Online (Sandbox Code Playgroud)

因此,我的位置按钮不可见,但蓝点是可见的.将两个布尔值更改为false,然后不再有效.没有蓝点,但没有位置更新.我有点困惑.我究竟做错了什么?

谢谢

android google-maps-markers android-maps-v2

8
推荐指数
1
解决办法
7979
查看次数

片段和onConfigurationChanged

我正在尝试用活动做一些事情,但是在一个片段中.我所做的是使用活动:

首先停止旋转设备时重新启动活动 android:configChanges="keyboardHidden|orientation|screenSize"

在我的活动中添加:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

 setContentView(R.layout.main);
}
Run Code Online (Sandbox Code Playgroud)

因此,获取活动不会重新启动,而是重新加载main.xml,以使用layout-land

现在我有一个显示viewpager的活动,其中包含三个片段.一切正常.旋转的检测在碎片中

public class FRG_map_web extends Fragment  {

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        Log.i("myLogs", "Rotation");

    }
Run Code Online (Sandbox Code Playgroud)

问题是片段不使用setContentView(R.layout.main); 这是代码:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.frg.myFragment, null); 
Run Code Online (Sandbox Code Playgroud)

我试着用:

LayoutInflater inflater = inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

view = inflater.inflate(R.layout.frg.myFragment, null); 

...

LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

view = inflater.inflate(R.layout.frg.myFragment, null); 

...

LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

view = inflater.inflate(R.layout.frg.myFragment, …
Run Code Online (Sandbox Code Playgroud)

android android-fragments layout-inflater

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

使用FTPS将文件从android传输到服务器

我在我的Android应用程序中使用Apache Commons FTP库

我通过FTPS建立连接,虽然它与服务器完美连接,但在传输文件时遇到问题.

出于安全原因,订购应用程序的客户端在使用PROT P时请求在数据连接上恢复TLS会话.

因此,我在服务器上启用了此选项:

在此输入图像描述

正如我所说,我可以连接到服务器,但不能传输文件. 如果我取消激活"使用PROT P时数据连接上所需的TLS会话恢复"框,则传输正常.

我正在寻找一种使用库进行文件传输的方法,但是没有成功,我知道必须有一种方法.

我给你相关代码的一部分:

TransferImagenesFTP.ftpClient = new FTPSClient();

TransferImagenesFTP.ftpClient.connect(InetAddress.getByName("XXX_XXX_XX_X"), 26);
TransferImagenesFTP.ftpClient.enterLocalPassiveMode();
TransferImagenesFTP.ftpClient.setBufferSize(1024000);
TransferImagenesFTP.ftpClient.login("xxxxxx", "zzzzzz");
TransferImagenesFTP.ftpClient.execPROT("P");
TransferImagenesFTP.ftpClient.type(FTP.BINARY_FILE_TYPE);
Run Code Online (Sandbox Code Playgroud)

我感谢任何帮助,谢谢.

java android ftp-client ftps apache-commons-net

7
推荐指数
1
解决办法
1222
查看次数

android中gridview的行数

我正在尝试创建一个只有两行的gridview.我的目的是使它看起来像一个有两排的画廊,一个在另一个上面,并有一个水平卷轴.我看到您可以更改gridview中的列数,但无法找到如何更改行数.我感谢任何帮助,如果不可能使用gridview也欣赏任何想法.

android gridview rows

6
推荐指数
1
解决办法
3743
查看次数

在片段中使用YouTube API

我在项目中使用了新的YouTube API.使用文档示例,它可以正常工作:

public class Test extends  YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {

    String urlVideo;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        urlVideo="5lbVNYAeFiQ";

        YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
        youTubeView.initialize("MY_API_KEY", this);

    }

    public void onInitializationFailure(Provider arg0,YouTubeInitializationResult arg1) {
        Toast.makeText(this, "Error ", Toast.LENGTH_LONG).show();  
    }

    public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1,boolean wasRestored) {
        if (!wasRestored) {
            arg1.loadVideo(urlVideo);
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

但是在我的项目中,我正在使用包含ViewPager的主要活动ViewPager显示片段,问题在于我想在ViewPager的一个片段中显示YouTubePlayer.通常,使用youtube的活动,扩展YouTubeBaseActivity.

extends YouTubeBaseActivity implements ... { 
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何在一个从片段扩展的活动中显示YouTube播放器?

我搜索过,但无法找到有关我的问题的信息.

我真诚地感谢你的帮助.

最好的祝福

android youtube-api android-fragments android-viewpager

6
推荐指数
1
解决办法
1万
查看次数

使用 Apache-POI 获取 docx 的每个段落的行

我正在为我的应用程序使用库 Apache-POI。具体来说,POIshadow-all (ver. 3.17) 用于阅读 Word 文档。我成功地提取了每个段落,如下所示:

在此处输入图片说明

我真正需要的是提取每一,如下所示:

在此处输入图片说明

提取每个段落的代码是这样的:

 try {

            val fis = FileInputStream(path.path + "/" + document)
            val xdoc = XWPFDocument(OPCPackage.open(fis))

            val paragraphList: MutableList<XWPFParagraph> = xdoc.paragraphs

            private val newParagraph = paragraph.createRun()

                ...

            for (par in paragraphList) {

                    var currentParagraph = par.text
                    Log.i("TAG","current: $currentParagraph")

                        ...
Run Code Online (Sandbox Code Playgroud)

正如预期的那样,变量 currentParagraph 返回整个段落。但是,我需要一个名为 currentLine 的变量,它返回一行。

我在 stackoverflow 和其他网站上研究过这个问题。我找到了一些建议,但没有一个适合我。我还尝试通过 ctr 和使用 XWPFRun 获取日期,但没有成功。

对于如何进行的任何建议,我将不胜感激。

在此先感谢您的帮助。

java android docx apache-poi kotlin

6
推荐指数
1
解决办法
399
查看次数

用于标记代码的Eclipse插件

是否有Eclipse插件来标记代码,就像使用荧光笔一样.任何人都知道这是否可行?

eclipse plugins

5
推荐指数
1
解决办法
1497
查看次数

GridView项之间的空格

我在我的代码中使用了GridView.我有空间问题.这是我的问题:

在此输入图像描述

当文字很短没问题,但问题是什么时候更长.我想得到这个:

在此输入图像描述

这是我的GridView:

<GridView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_margin="5dp"
            android:layout_weight="1"
            android:divider="@color/transparente"
            android:horizontalSpacing="4dp"
            android:longClickable="true"
            android:numColumns="2"
            android:scrollbars="none"
            android:verticalSpacing="4dp" >
        </GridView>
Run Code Online (Sandbox Code Playgroud)

这是GridView元素的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:gravity="center_vertical"
    android:paddingLeft="5dp" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="5dp"
        android:paddingTop="2dp" >

        <TextView
            android:id="@+id/textView_title_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text text text text text text"
            android:textColor="@color/blanco"
            android:textSize="@dimen/titulos" />

        <TextView
            android:id="@+id/textView_alarm_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text text text text text text"
            android:textColor="@color/blanco"
            android:textSize="@dimen/contenido" />

        <TextView
            android:id="@+id/textView_alarm_days"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Text text text text text text"
            android:textColor="@color/blanco"
            android:textSize="@dimen/contenido" />
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我试图使用android: stretchMode = "spacingWidth", …

android gridview space

5
推荐指数
1
解决办法
1万
查看次数