如果另一个文本视图正在更改,TextView选取框将不起作用

时间:2017-11-30 08:53:03

标签: android android-layout textview

我的文字视图就像那样

<TextView
    android:id="@+id/current_podcast_name"
    fontPath="@string/font_bold"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="0dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:freezesText="true"
    android:gravity="center_horizontal"
    android:marqueeRepeatLimit="marquee_forever"
    android:scrollHorizontally="true"
    android:singleLine="true"
    android:textColor="#ffffff"
    android:textSize="20sp"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toTopOf="@id/current_podcast_date"
    tools:ignore="Deprecated,HardcodedText,MissingPrefix" />

我添加了这段代码 的 current_podcast_name.setSelected(真);

  1. 实际上,大帐篷现在正在运作。
  2. 但是,当我更改另一个textview主体时,它不起作用。
  3. 例如 我打开这个标签

    @Override
    public void onResume() {
        super.onResume();
        if (!mSeekbarBroadcastIsRegistered) {
            LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(broadcastSeekbarReceiver, new IntentFilter(PowerService.LOCAL_BROADCAST_PODCAST_SEEKBAR));
            mSeekbarBroadcastIsRegistered = true;
        }
    }
    
    private BroadcastReceiver broadcast = new BroadcastReceiver() {
    
            @Override
            public void onReceive(Context context, Intent intent) {
    
                updateSeekBarUI(intent);
    
            }
        };
    
    private void updateSeekBarUI(Intent intent) {
            int counter = intent.getIntExtra("counter",0);
            int mediamax = intent.getIntExtra("mediamax",0);
            int songEnded = intent.getIntExtra("song_ended",0);
    
            podcastsSeekBar.setMax(mediamax);
            podcastsSeekBar.setProgress(counter);
    
            //txt_SongTotalDuration.setText(PowerServiceHelper.milliSecondsToTimer(mediamax)); 
            //txt_CurrentDuration.setText(PowerServiceHelper.milliSecondsToTimer(counter));
    
            if( songEnded == 1 ){
                //do something
            }
        }
    

    我从媒体播放器收到当前持续时间,每1秒我更改一次textview。所以,如果我打开txt_SongTotalDuration,txt_CurrentDuration,则选取框不起作用...

    我没有找到任何解决方案。

    谢谢

    here this is the problem GIF

1 个答案:

答案 0 :(得分:0)

这样做,这可能会对你有所帮助:

<TextView
        android:id="@+id/marque_scrolling_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:padding="16dp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="We publish useful materials from the detailed description without much 'water', to working (audited) examples.Our main task - is to bring the materials most simple and understandable to the reader."
        android:textSize="20sp" />

活动:

TextView marque = (TextView) this.findViewById(R.id.marque_scrolling_text);
        //the same one line of code
        marque.setSelected(true);

这对我有用。