小编ale*_*tkd的帖子

方向改变android时保存活动状态

我有一个aacplayer应用程序,我希望在方向从纵向更改为横向时保存我的活动状态.TextViews似乎不是空的,我尝试使用以下方法冻结我的textview:

android:freezesText="true"
Run Code Online (Sandbox Code Playgroud)

我的清单:

android:configChanges="orientation"
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

@Override
    public void onConfigurationChanged(Configuration newConfig){
        super.onConfigurationChanged(newConfig);
        setContentView(R.layout.main2);
Run Code Online (Sandbox Code Playgroud)

因此,当方向更改为横向时,我可以看到我的layout-land main2.xml,它可以工作,但我的textview出来并显示为空.流媒体音乐很棒.我可以在方向更改时收听它,但每次更改设备的方向时,文本视图中的文本都会消失.

我应该怎么做才能解决这个问题,以便保存状态?

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
....
....
Run Code Online (Sandbox Code Playgroud)

非常感谢你.

android

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

Javascript regexp使用val().match()方法

我正在尝试使用以下规则验证名为phone_number的字段:

第一个数字应为3然后是另外9个数字,因此总共10个数字示例:3216549874

或者可以是7个数字1234567

这里我有我的代码:

        if (!($("#" + val["htmlId"]).val().match(/^3\d{9}|\d{7}/)))
            missing = true;
Run Code Online (Sandbox Code Playgroud)

为什么不工作:(当我把它放入在线正则表达式检查器显示良好.

javascript jquery

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

创建音频频谱可视化器 android 应用程序

我正在尝试制作像音频频谱可视化器这样的东西:

在此处输入图片说明

我已经有了连接到音频流并播放音乐的 AAC 播放器。我现在如何添加此可视化组件?

android android-layout

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

自定义通知选框文本不能正常工作

嗨我试图在通知管理器选框中制作我的文本的一部分,但没有工作我试过这个:

  <TextView
    android:id="@+id/title_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:gravity="bottom"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"                                     
    android:focusable="true"
    android:focusableInTouchMode="true"              
    android:singleLine="true"
    android:textSize="15sp"
    android:textStyle="bold" >
  </TextView>
Run Code Online (Sandbox Code Playgroud)

在我的.java中我使用remoteview:

Notification notification = new Notification(icon, tickerText, when);
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);

contentView.setTextViewText(R.id.title_text, "This is a very long text which is not fitting in the screen so it needs to be marqueed");
Run Code Online (Sandbox Code Playgroud)

我想为那个title_text设置选取框这是一个非常长的文本,不适合在屏幕上,所以它需要被标记

但是大帐篷不起作用只是保持静态我能做什么?

谢谢.

android android-notifications

4
推荐指数
1
解决办法
3823
查看次数