2017-01-13 12 views
0

私はこの奇妙な「バグ」を持っています。アプリリストからアプリを開いた場合にのみテキストスクロールが表示されますが、アンドロイドの戻るボタンを使用して戻ると表示されますが、自分の戻るボタンをアプリケーション内に置くか、画面を回転させます。あなたは非同期タスクを実行するので、前にi」は「ONSTARTを()」と呼んでいない場合はどうやらそれが動作テキストビューが非同期呼び出しでスクロールしない

private RelativeLayout createRSSFeed(Object output, int i){ 
    int height = dpToPx(this, 200); 

    /** FEED FRAME */ 
    RelativeLayout relativeLayoutFeed = new RelativeLayout(this); 
    RelativeLayout.LayoutParams relativeLayoutFeedParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height); 
    relativeLayoutFeed.setLayoutParams(relativeLayoutFeedParams); 
    relativeLayoutFeed.setBackgroundColor(Color.GRAY); 
    relativeLayoutFeed.setPadding(0, dpToPx(this, 3), 0, 0); 
    //relativeLayoutFeed.setId(R.id.reservedRelativeLayoutRSSFeedId + i-1); 
    relativeLayoutFeed.setId(R.id.reservedRelativeLayoutRSSFeedId); 
    relativeLayoutFeed.setOnTouchListener(this); 


    /** FEED TEXT FRAME */ 
    RelativeLayout relativeLayout_subText = new RelativeLayout(this); 

    /** TITLE */ 
    TextView textViewTitle = new TextView(this); 

    textViewTitle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(this, 30))); 

    textViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, dpToPx(this, 24)); 


    // TITLE SCROLLING <- the problem? 
     textViewTitle.setSingleLine(true); 
     textViewTitle.setHorizontallyScrolling(true); 
     textViewTitle.setMarqueeRepeatLimit(-1); 
     textViewTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE); 

     textViewTitle.setFocusableInTouchMode(true); 
     textViewTitle.setFocusable(true); 
     textViewTitle.requestFocus(); 

     textViewTitle.setSelected(true); 


    textViewTitle.setTypeface(null, Typeface.BOLD); 
    textViewTitle.setTextColor(Color.WHITE); 
    textViewTitle.setPadding(dpToPx(this, 5), 0, dpToPx(this, 5), 0); 
    textViewTitle.setText("Lorem Ipsum"); 
    textViewTitle.setText(fromHtml(((List<Entry>)output).get(i-1).title)); 
    /** BODY */ 
    TextView textViewBody = new TextView(this); 
    textViewBody.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(this, 30)));//50px 
    //textViewBody.setTextSize(dpToPx(this, 5)); //10px 
    textViewBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, dpToPx(this, 12)); 
    textViewBody.setMaxLines(2); 
    textViewBody.setTextColor(Color.WHITE); 
    textViewBody.setPadding(dpToPx(this, 3), 0, dpToPx(this, 3), 0); 
    textViewBody.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."); 
    textViewBody.setText(fromHtml(((List<Entry>)output).get(i-1).description)); 



    linearLayout_subText.addView(textViewTitle); 
    linearLayout_subText.addView(textViewBody); 


    return relativeLayoutFeed; 
} 

答えて

0

//this override the implemented method from asyncTask 
@Override 
public void processFinish(final Object output){ 
    //Here you will receive the result fired from async class 
    //of onPostExecute(result) method. 

    //some irrelevant code here 

     LinearLayout mainRSSLayout = (LinearLayout) findViewById(R.id.main_rss_layout); 

     RelativeLayout relativeLayoutFeed = createRSSFeed(output, i); 


      //plug in 
      linearLayoutFeedPair.addView(relativeLayoutFeed, linearLayoutFeedPairParam); 
      linearLayoutFeedPair.addView(relativeLayoutFeed2, linearLayoutFeedPairParam); 
      mainRSSLayout.addView(linearLayoutFeedPair); 

     mainRSSLayout.addView(relativeLayoutFeed); 

} 

と実際のprogramaticalの作成: はここに関連するコードです問題を解決した:

public void onStart() { 
    SystemClock.sleep(1000); 
    super.onStart(); 


    System.out.println("on start"); 
}