에서 alertDialog.setMessage()에서 색상 문자열 변수를 보여,이 지금까지내에 AlertDialog 내 API 26 인이 <a href="https://i.stack.imgur.com/fbMJZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fbMJZ.png" alt="enter image description here"></a></p> <p>과 같이 원하는
alertDialog.setTitle("Warning");
alertDialog.setMessage(Html.fromHtml("Are you sure"+"\n"+"\n"+"<font color='#00bfff'><br><br><b>Est. Total Cost : $ 9.00 </b></font>",Build.VERSION.SDK_INT));
내 코드하는 방법
보시다시피 저는 문자열에 9.00을 직접 넣었습니다. 지금은 9.00을 estCost라는 문자열 변수로 만들고 싶습니다. estCost는 내 코드의 계산에 따라 변경할 수 있습니다.
alertDialog.setMessage()에서 "색상이있는 문자열 변수"estCost를 어떻게 표시합니까?
나는 코드를
String estCost = calculate(10) //calculate method will return a double in string.
alertDialog.setTitle("Warning");
alertDialog.setMessage(Html.fromHtml("Are you sure"+"\n"+"\n"+"<font color='#00bfff'><br><br><b>Est. Total Cost : $ <var> estCost </var></b></font>",Build.VERSION.SDK_INT));
을 다음 시도했지만 작동하지 않습니다. 제발 도와주세요! 감사.
' "+ estCost +" " –
Dope !!!!!! 나는 오늘의 형제를 구한다 ~ 나는 그것을 인터넷에서 검색했다. 방금 진짜 빨리 죽였어 ~ 고마워. –