Hi I have problem with NavigationView . I use this code :
nav = FindViewById<NavigationView>(Resource.Id.nav_view);
View vie = nav.GetHeaderView(0);
TextView title1 = vie.FindViewById<TextView>(Resource.Id.title1);
TextView title2 = vie.FindViewById<TextView>(Resource.Id.title2);
ImageView logo_menu = vie.FindViewById<ImageView>(Resource.Id.imageView1);
title1.Text = MenuLayout.text1;
title1.TextSize = MenuLayout.text1_size;
title1.SetTextColor(MenuLayout.text1_color);
title2.Text = MenuLayout.text2;
title2.TextSize = MenuLayout.text2_size;
title2.SetTextColor(MenuLayout.text2_color);
logo_menu.SetImageBitmap(MenuLayout.menu_Image);
vie.SetBackgroundColor(Android.Graphics.Color.Black);
The last line not working , nothing change ... How Can I set background of header Programmatically ? My secend problem is change text and icon items of Navmenu (Can I change when program work ? How override this)
Related
How can I put that little number in the same column (textView) or how can I add two of them .
I have tried linearlayout horizantal but it did not worked How I want that text view to be look like;
ı want to add number like this image
//this my textView for adding to rows
txtColumnArray[i] = new TextView(this);
txtColumnArray[i].setTextColor(Color.BLUE);
txtColumnArray[i].setAllCaps(true);
txtColumnArray[i].setGravity(Gravity.CENTER);
txtColumnArray[i].setTypeface(Typeface.DEFAULT.DEFAULT_BOLD);
txtColumnArray[i].setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f);
// my last try is spanable but it is not working , I thought it may be
// coz of textView properties but couldnt find it.
spanableForQuestionNumbers[questionNumbersCount] = new SpannableString(questionNumbersCount + " " + LetterFormat[count]);
spanableForQuestionNumbers[questionNumbersCount].setSpan(new SuperscriptSpan(), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
txtColumnArray[i].setText(spanableForQuestionNumbers[questionNumbersCount]);
trCrosswordRow.addView(txtColumnArray[i]);
How can I access to click on 2nd link inside TextView? So far I tried:
AndroidElement d = (AndroidElement) driver.findElement(By.xpath("//android.widget.TextView[#text='Notice']"));
d.click();
And using:
driver.findElement(By.Id("com.optimum.rdvr.mobile:id/toc_text"));
just clicks on 1st link. And I need to get 2nd link. I want to click on "Mobile Privacy Notice" Any one has suggestion?
You can use Linkify
String termsOfUse = getResources().getString(R.string.terms_of_use);
String privacyNotice = getResources().getString(R.string.privacy_notice);
legalDescription.setText(
String.format(
getResources().getString(R.string.message),
termsOfUse,
privacyNotice )
);
//add the links
Pattern privacyNoticeMatcher = Pattern.compile(privacyNotice);
Linkify.addLinks(legalDescription, privacyNoticeMatcher , "privacy:");
Pattern termsOfUseMatcher = Pattern.compile(termsOfUse);
Linkify.addLinks(legalDescription, termsOfUseMatcher , "termsOfUse:");
via Multiple Clickable links in TextView on Android
I am learning Android and I use this tutorial: http://www.androidhive.info/2012/06/android-populating-spinner-data-from-sqlite-database/ to generate Spinner with data from database.
This working ok, but i can't get selected item.
final Spinner spinner = (Spinner) findViewById(R.id.spinner); //this is ok
and next i would like get selected item:
Log.i("test", spinner.getSelectedItem().toString());
this return me:
+++ LOG: entry corrupt or truncated
EDIT:
I try also:
Log.i("test", spinner.getSelectedView().toString());
but this return:
android.widget.TextView#410a2ae8
Try the following:
TextView textView = (TextView)spinner.getSelectedView();
String result = textView.getText().toString();
I read some thread in this topic, but I have not found the solution.
I would like to use the scrollHorizontally attribute on a TextView, but from Java code.
Here's what I tried:
nameTextView = new TextView(context);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
nameTextView.setId(R.id.header_text_id);
nameTextView.setGravity(Gravity.CENTER | Gravity.LEFT);
nameTextView.setSingleLine();
nameTextView.setHorizontallyScrolling(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
nameTextView.setFocusableInTouchMode(true);
nameTextView.setMarqueeRepeatLimit(-1);
nameTextView.setFocusable(true);
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/robotocondensed.ttf");
nameTextView.setTypeface(tf);
nameTextView.setTextColor(getResources().getColor(android.R.color.white));
I set the text later. The text does not scroll, what can be the problem here?
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
Then set:
yourTextView.setMovementMethod(new ScrollingMovementMethod())
excelent article about how to make an horizontal scrollable textview in android, It works!!!
http://gabrielbl.com/2013/08/09/android-auto-horizontal-scrolling-marquee-textview/
I am having a problem with a custom view I am currently doing for an app on android, I know there are many questions related with inflaters, but I cannot get around this problem.
the inflater i working just fine, but it should be doing the loop 3 times and is only doing it 1 so I only get one view on my final layout.
the relevant part of the code is this one
void populate(String strcline, String url){
lLfD = (LinearLayout)findViewById(R.id.lLfD);
try{
JSONArray a1 = new JSONArray(strcline);
for(int i = 0; i < a1.length(); i++){
JSONArray a2 = a1.getJSONArray(i);
final String fUserId = a2.getString(0);
String userName = a2.getString(1);
String userPicture = url + a2.getString(2);
View child = getLayoutInflater().inflate(R.layout.cellevery, lLfD);
ImageView avatar = (ImageView)findViewById(R.id.cellAvatar);
downloadFile(userPicture, avatar);
TextView cellName = (TextView)findViewById(R.id.cellName);
cellName.setText(userName);
lLfD.addView(child);
}
}catch(Exception e){
}
pDialog.dismiss();
}
You look like you need to run findViewById only on the inflated view, otherwise it will just find the first one which is only the first one in your loop:
View child = getLayoutInflater().inflate(R.layout.cellevery, lLfD);
ImageView avatar = (ImageView)child.findViewById(R.id.cellAvatar);
downloadFile(userPicture, avatar);
TextView cellName = (TextView)child.findViewById(R.id.cellName);
cellName.setText(userName);
Here's an explanation of findViewById in your loop:
Loop 1:
1LfD->child1->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds this one)
Loop 2:
1Lfd->
child1->R.id.cellAvatar
child2->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds the child1.cellAvatar again)
Loop 3:
1LfD->
child1->R.id.cellAvatar
child2->R.id.cellAvatar
child3->R.id.cellAvatar (findViewById(R.id.cellAvatar) finds the child1.cellAvatar again)
by using child.findViewById(R.id.cellAvatar), it ensures that you find the correct R.id.cellAvatar for each run of the loop.
Does that make sense?
Update 2:
When you call:
getLayoutInflater().inflate(R.layout.cellevery, lLfD);
You are already setting the parent view as the second argument so you don't need to call:
lLfD.addView(child);