cancel
Showing results for 
Search instead for 
Did you mean: 

How Change TextView Colour

Former Member
0 Kudos

Dear Experts,

I am new to java and WebDynpro, I need your help ..

How to change programmatically <b>TextView</b> control Font color or BackGround Color, and where i can write that.

Because depend on textview value it should change color indicator

Regards

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

It's answered.

Former Member
0 Kudos

Hi Wrao,

Create a context variable(Say TextViewColour) and assign the type as com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor (Choose this type from ur Local Dictionary->uielementdefinitions)

Then bind this variable to SematicColor pty of TextView.

From ur program, u can change the color as critical by

wdContext.currentContextElement().setTextViewColour(WDTextViewSemanticColor.CRITICAL);

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi Wrao,

You have to use WebDynPro themes to change colors.

But in WebDynPro some certain colors you can apply.

There is one property semanticcolor of TextView.You try with that property.

Hope this will help.

Thx & rgds

AW

Former Member
0 Kudos

Dear Adams,

thank you for your quick Reply, I told you even i am new to java, I dont know how assigne the color througu programetic, please send u send how to do

like this

wdthis.wdview.textview.sementiccolor = colour ?

thank you..

Former Member
0 Kudos

Not Programatically.

Just insert a textview UI element to View change the sematiccolor property.

Thx & Rgds

AW

Former Member
0 Kudos

Hi,

While applying color for TextView programatic use this coding,

IWDTextView txt= (IWDTextView)view.createElement(IWDTextView.class,"TextView");

txt.setSemanticColor(WDTextViewSemanticColor.POSITIVE);

Former Member
0 Kudos

Hi,

Using a context attribute depends on you requirement.

If their is only one textView in your view then you can very well use

context attribute method. But if their are more than one textview whose coclur has to be changed during runtime, then you cannot bind the same context attribute to all the text view. In turn you have to create context attributes of type com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor equal tono of textviews.

If their are more then one textview whose color has to be changed during runtime,then you can do this in wdDoModifyview method of your view.

suppose you have two textviews textview1 and textview2 then

public static void wdDoModifyView(IPrivateFile_Sample_View wdThis, IPrivateFile_Sample_View.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if(wdContext.currentContextElement().getTextView1Value.equals("<comparing value>"))

{

IWDTextView textView1 = (IWDTextView)view.getElement("textview1");

textView1.setSemanticColor(WDTextViewSemanticColor.<choose your color>);

}

if(wdContext.currentContextElement().getTextView2Value.equals("comparing value"))

{

IWDTextView textView2 = (IWDTextView)view.getElement("textview2");

textView2.setSemanticColor(WDTextViewSemanticColor.<choose your color>);

}

//@@end

}

Former Member
0 Kudos

Dear Suresh,

your suggetions is worked, but I need change Background colour,

suppose if textview values is negitive the background colour wil change to red or standard colour.

please suggest me

Former Member
0 Kudos

Dear Shriram Kabra ,

you are great, you know exactly what the group member need, that's why you are one of the top ranker in the group, I appreciate you, but i need change textview background colour if not possible direct way give me alternate way..

please

Former Member
0 Kudos

Hi,

If you want to change the background of the textview UI element,

then this is possible if your Layout data for UI element is GridLayout or MatrixLayout.

You can change the cell background colour as follows

IWDTextView textView = (IWDTextView)view.getElement("<textview ID>");

IWDGridData gridData = (IWDGridData)textView.createLayoutData(IWDGridData.class);

gridData.setCellBackgroundDesign(WDCellBackgroundDesign.<choose your colour>);

OR

IWDTextView textView = (IWDTextView)view.getElement("<TextView ID>");

IWDGridData data = (IWDGridData)textView.getLayoutData();

data.setCellBackgroundDesign(WDCellBackgroundDesign.<choose the background>);

Former Member
0 Kudos

For changing the default themes of the webDynpro

Check out the blog

/people/lisha.peter/blog/2005/07/07/make-your-webdynpro-application-theme-specific