2014-01-18 2 views
0

textview를 확장하는 컨트롤을 만들었습니다. 불행히도 내 활동에서 setText 또는 setTextSize와 같은 함수를 호출하려고해도 아무 일도 일어나지 않습니다.android는 재정의 된 textview 컨트롤에서 속성을 변경할 수 없습니다.

TextView l = (TextView) this.findViewById(R.id.dlgStarup_lblHeading); 
    myTextView lblHeading = new myTextView(l, _theme, _CONTROLTYPE.SUBTITLE); 

    myTextView.setText("Any text can go here"); //this doesn't work 

하지만 그건 후 컨트롤의 속성을 설정 할 수 없다는 :

나는 표준 텍스트 뷰를 받아들이는 생성자를 만들고 다음 코드와 컨트롤을 작성하여 테마 문제를 해결하기 위해 관리 진짜 문제가 여기

의 원인이 생성 된 것은 내 myTextView 클래스

public class myTextView extends TextView 
{ 

    public enum _CONTROLTYPE 
    { 
     TITLE,SUBTITLE,MESSAGE,LABEL,LARGE_LABEL,ICON; 
    } 

    public myTextView(TextView _t, myTheme _theme, _CONTROLTYPE _controltype) 
    { 
     super(_t.getContext()); 
     this.setTheme(_t, _theme, _controltype); 
    } 

    public myTextView(Context _context, AttributeSet _attrs, int _defStyle) 
    { 
     super(_context, _attrs, _defStyle); 
     // TODO Auto-generated constructor stub 
    } 

    public myTextView(Context _context, AttributeSet _attrs) 
    { 
     super(_context, _attrs); 
     // TODO Auto-generated constructor stub 
    } 

    private void setTheme(TextView _control, theme _theme, _CONTROLTYPE _controltype) 
    { 
     _control.setTextColor(_theme.colours.titleText); 
     _control.setTextSize(_theme.fonts.getPointSize(myTheme._POINTSIZES.TITLE)); 
    } 

      //this didn't work 
    public void setThemeOld(theme _theme, _CONTROLTYPE _controltype) 
    { 
     //I tried calling both this.setText.... and super.setText..., neither changed the apperance of my control 
     this.setTextColor(_theme.colours.titleText); 
     this.setTextSize(_theme.fonts.getPointSize(myTheme._POINTSIZES.TITLE)); 

     //I also tried putting this here - it had no effect 
     this.invalidate() 
    } 
} 

(편집) 가득 요청에 따라 textviews가 initilized되는 코드 :

protected Dialog_Startup(Context _context, boolean _cancelable, OnCancelListener _cancelListener, theme _theme) 
{ 
    super(_context, _cancelable, _cancelListener); 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.setContentView(R.layout.dialog_startup); 

    TextView l = (TextView) this.findViewById(R.id.dlgStarup_lblHeading);  
    myTextView lblHeading = new myTextView(l, _theme, _CONTROLTYPE.SUBTITLE); 

    l = (TextView) this.findViewById(R.id.dlgStarup_lblProgress); 
    myTextView lblMessage = new myTextView(l,_theme, _CONTROLTYPE.LABEL); 
    lblMessage.setText("THIS ISN'T WORKING"); //this isn't workig 

    Intent i = new Intent(_context, DataService.class); 
    //_context.startService(i); 

} 
+0

에서 oncreate의 코드를 게시 할 수 있습니까? –

답변

0

난 당신이 사용자 정의 텍스트 뷰에서 새로운 객체를 생성하고 XML 레이아웃에서 텍스트 뷰를 사용하지 않은 문제 (당신은 당신의 코드를 게시 할 때까지), 도움이 코드를하려고 생각 너

TextView l = (TextView) this.findViewById(R.id.dlgStarup_lblHeading); 
myTextView lblHeading = new myTextView(l, _theme, _CONTROLTYPE.SUBTITLE); 
l.setText("Any text can go here"); 
+0

네, 그게 효과가 있겠지만 ... 실제로 오버라이드 된 클래스가 함수를 호출 할 때 작동하지 않는 문제를 해결하지 못합니다 – LairdPleng

+0

재정의 된 클래스를 사용하면 무엇을 의미합니까 ?? –

+0

죄송합니다. 확장 클래스 ... myTextView – LairdPleng

관련 문제