List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf)
From source file:com.android.widget.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;// www. ja v a 2s .co m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } else { tabView = createDefaultTabView(getContext()); tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i).toString().toUpperCase()); tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); tabTitleView.setTextColor(getResources() .getColor(Util.getResourceFromAttribute(getContext(), R.attr.font_actionbar_selected))); } } }
From source file:com.RSMSA.policeApp.OffenceReportForm.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REPORT_RESULT) { if (resultCode == RESULT_OK) { // code for result final Bundle bundle = data.getExtras(); Log.d("Database", "count at parent is " + count); desc = bundle.getStringArrayList("desc"); type = bundle.getStringArrayList("type"); uids = bundle.getStringArrayList("uids"); OffenseListActivity.offenseDesc.clear(); backFromChild = true;//from ww w.j a v a2 s . com Log.d(TAG, "number of ids = " + uids.size()); try { Log.d(TAG, " test data = " + invalidLicence); } catch (Exception e) { } if (invalidLicence != null && !invalidLicence.equals("")) { String offenceUid = invalidLicence; boolean offenceIncluded = false; for (String i : uids) { if (offenceUid.equals(i)) { offenceIncluded = true; } } if (!offenceIncluded) { Log.d(TAG, " desc sze before = " + desc.size()); IroadDatabase db = new IroadDatabase(getApplicationContext()); int counter = uids.size(); uids.add(offenceUid); desc.add(db.getAnOffenceDetail(false, offenceUid)); type.add(db.getAnOffenceDetail(true, offenceUid)); } } //TODO implement the above for expired licence count = desc.size(); int counter = desc.size(); if (counter > 0) { offencesSelectedTextView.setVisibility(View.VISIBLE); submit_layout1.setVisibility(View.VISIBLE); } else { offencesSelectedTextView.setVisibility(View.GONE); submit_layout1.setVisibility(View.GONE); } offencesSelected = ""; for (int i = 0; i < counter; i++) { if (i == counter - 1) { offencesSelected = offencesSelected + desc.get(i); offenceList = offenceList + desc.get(i); } else { offencesSelected = offencesSelected + desc.get(i) + "\n\n"; offenceList = offenceList + desc.get(i) + ","; } } offencesSelectedTextView.setText(offencesSelected); offensesCommittedTextview.setText(offencesSelected); amountToReport = 0; for (int i = 0; i < count; i++) { Log.d(TAG, "type = " + type.get(i)); try { amountToReport += Integer.parseInt(type.get(i)); } catch (Exception e) { e.printStackTrace(); } } Log.d(TAG, "amount to report = " + amountToReport); TextView offenceCost = (TextView) findViewById(R.id.costs); offenceCost.setTypeface(MainOffence.Roboto_Regular); offenceCost.setText(amountToReport + ""); } if (resultCode == RESULT_CANCELED) { } } }
From source file:com.moonpi.swiftnotes.MainActivity.java
@Override protected void onResume() { super.onResume(); TextView actionBarTitleView = null; if (actionBarTitle != 0) actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { if (lobsterTwo != null) actionBarTitleView.setTypeface(lobsterTwo); }/*ww w. j a va2s .c o m*/ }
From source file:com.affectiva.affdexme.MainActivity.java
void initializeUI() { //Get handles to UI objects ViewGroup activityLayout = (ViewGroup) findViewById(android.R.id.content); progressBarLayout = (RelativeLayout) findViewById(R.id.progress_bar_cover); permissionsUnavailableLayout = (LinearLayout) findViewById(R.id.permissionsUnavialableLayout); metricViewLayout = (RelativeLayout) findViewById(R.id.metric_view_group); leftMetricsLayout = (LinearLayout) findViewById(R.id.left_metrics); rightMetricsLayout = (LinearLayout) findViewById(R.id.right_metrics); mainLayout = (RelativeLayout) findViewById(R.id.main_layout); fpsPct = (TextView) findViewById(R.id.fps_value); fpsName = (TextView) findViewById(R.id.fps_name); cameraView = (SurfaceView) findViewById(R.id.camera_preview); drawingView = (DrawingView) findViewById(R.id.drawing_view); settingsButton = (ImageButton) findViewById(R.id.settings_button); cameraButton = (ImageButton) findViewById(R.id.camera_button); screenshotButton = (ImageButton) findViewById(R.id.screenshot_button); progressBar = (ProgressBar) findViewById(R.id.progress_bar); pleaseWaitTextView = (TextView) findViewById(R.id.please_wait_textview); Button retryPermissionsButton = (Button) findViewById(R.id.retryPermissionsButton); //Initialize views to display metrics metricNames = new TextView[NUM_METRICS_DISPLAYED]; metricNames[0] = (TextView) findViewById(R.id.metric_name_0); metricNames[1] = (TextView) findViewById(R.id.metric_name_1); metricNames[2] = (TextView) findViewById(R.id.metric_name_2); metricNames[3] = (TextView) findViewById(R.id.metric_name_3); metricNames[4] = (TextView) findViewById(R.id.metric_name_4); metricNames[5] = (TextView) findViewById(R.id.metric_name_5); metricDisplays = new MetricDisplay[NUM_METRICS_DISPLAYED]; metricDisplays[0] = (MetricDisplay) findViewById(R.id.metric_pct_0); metricDisplays[1] = (MetricDisplay) findViewById(R.id.metric_pct_1); metricDisplays[2] = (MetricDisplay) findViewById(R.id.metric_pct_2); metricDisplays[3] = (MetricDisplay) findViewById(R.id.metric_pct_3); metricDisplays[4] = (MetricDisplay) findViewById(R.id.metric_pct_4); metricDisplays[5] = (MetricDisplay) findViewById(R.id.metric_pct_5); //Load Application Font and set UI Elements to use it Typeface face = Typeface.createFromAsset(getAssets(), "fonts/Square.ttf"); for (TextView textView : metricNames) { textView.setTypeface(face); }/*from w w w.j a va 2 s . c o m*/ for (MetricDisplay metricDisplay : metricDisplays) { metricDisplay.setTypeface(face); } fpsPct.setTypeface(face); fpsName.setTypeface(face); drawingView.setTypeface(face); pleaseWaitTextView.setTypeface(face); //Hide left and right metrics by default (will be made visible when face detection starts) leftMetricsLayout.setAlpha(0); rightMetricsLayout.setAlpha(0); /** * This app uses two SurfaceView objects: one to display the camera image and the other to draw facial tracking dots. * Since we want the tracking dots to appear over the camera image, we use SurfaceView.setZOrderMediaOverlay() to indicate that * cameraView represents our 'media', and drawingView represents our 'overlay', so that Android will render them in the * correct order. */ drawingView.setZOrderMediaOverlay(true); cameraView.setZOrderMediaOverlay(false); //Attach event listeners to the menu and edit box activityLayout.setOnTouchListener(this); //Attach event listerner to drawing view drawingView.setEventListener(this); /* * This app sets the View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. Unfortunately, this flag causes * Android to steal the first touch event after the navigation bar has been hidden, a touch event * which should be used to make our menu visible again. Therefore, we attach a listener to be notified * when the navigation bar has been made visible again, which corresponds to the touch event that Android * steals. If the menu bar was not visible, we make it visible. */ activityLayout.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int uiCode) { if ((uiCode == 0) && (!isMenuVisible)) { setMenuVisible(true); } } }); retryPermissionsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { requestCameraPermissions(); } }); }
From source file:com.arctech.stikyhive.ChattingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); recipientStkid = getIntent().getExtras().getString("recipientStkid"); chatRecipient = getIntent().getExtras().getString("chatRecipient"); chatRecipientUrl = getIntent().getExtras().getString("chatRecipientUrl"); senderToken = getIntent().getExtras().getString("senderToken"); recipientToken = getIntent().getExtras().getString("recipientToken"); noti = getIntent().getExtras().getBoolean("noti"); message = getIntent().getExtras().getString("message"); rows = getIntent().getExtras().getInt("rows"); pref = PreferenceManager.getDefaultSharedPreferences(this); ws = new JsonWebService(); dbHelper = new DBHelper(this); dialog = new ProgressDialog(this); listChatContact = new ArrayList<>(); listChatContact = dbHelper.getChatContact(); Log.i(" Chat Contact ", " " + listChatContact.size()); //to change font faceSemi_bold = Typeface.createFromAsset(getAssets(), fontOSSemi_bold); Typeface faceLight = Typeface.createFromAsset(getAssets(), fontOSLight); faceRegular = Typeface.createFromAsset(getAssets(), fontOSRegular); imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) { imageLoader.init(ImageLoaderConfiguration.createDefault(this)); }// w w w . j a v a 2s.com start = new Date(); SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm"); timeSend = oFormat.format(start); super.onCreate(savedInstanceState); setContentView(R.layout.chat); txtUserName = (TextView) findViewById(R.id.txtChatName); edTxtMsg = (EditText) findViewById(R.id.edTxtMsg); imgViewProfile = (ImageView) findViewById(R.id.imgViewChat); imgViewAddCon = (ImageView) findViewById(R.id.imgAddContact); lv = (ListView) findViewById(R.id.listView1); layoutLabel = (LinearLayout) findViewById(R.id.layoutLabel); txtLabel1 = (TextView) findViewById(R.id.txtLabel1); txtLabel2 = (TextView) findViewById(R.id.txtLabel2); txtLabel3 = (TextView) findViewById(R.id.txtLabel3); txtLabel2.setText(" " + chatRecipient + " "); txtLabel1.setTypeface(faceLight); txtLabel2.setTypeface(faceRegular); txtLabel3.setTypeface(faceLight); // lv.smoothScrollToPosition(adapter.getCount() - 1); for (ChatContact contact : listChatContact) { if (contact.getContactId().equals(recipientStkid)) { imgViewAddCon.setVisibility(View.INVISIBLE); layoutLabel.setVisibility(View.GONE); break; } } Log.i(TAG, " come back again"); adapter = new ChatArrayAdapter(getApplicationContext(), R.layout.messaging_listview, faceSemi_bold, faceRegular); lv.setAdapter(adapter); // adapter.add(new StikyChat(chatRecipientUrl, "Hello", false, "12.10.2015", "12.1.2014")); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); // BEGIN_INCLUDE (change_colors) // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids swipeRefreshLayout.setColorScheme(R.color.swipe_color_1, R.color.swipe_color_2, R.color.swipe_color_3, R.color.swipe_color_4); limitMsg = 7; // END_INCLUDE (change_colors) swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.i(" Refresh Layout ", "onRefresh called from SwipeRefreshLayout"); if (limitMsg < rows) { Log.i("Limit Message ", " " + limitMsg); limitMsg *= 2; fetchRecords(); } else if (limitMsg > rows && (limitMsg - rows < 7)) { fetchRecords(); } else { Log.i("No data ", "to refresh"); swipeRefreshLayout.setRefreshing(false); Toast.makeText(getApplicationContext(), "No data to refresh!", Toast.LENGTH_SHORT).show(); } // initiateRefresh(); } }); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout headerLayout = (LinearLayout) findViewById(R.id.header); View header = inflator.inflate(R.layout.header, null); TextView textView = (TextView) header.findViewById(R.id.textView1); textView.setText("StikyChat"); textView.setTypeface(faceSemi_bold); textView.setVisibility(View.VISIBLE); headerLayout.addView(header); LinearLayout layoutRight = (LinearLayout) header.findViewById(R.id.layoutRight); layoutRight.setVisibility(View.GONE); txtUserName.setText(chatRecipient); Log.i(TAG, "Activity Name " + txtUserName.getText().toString()); txtUserName.setTypeface(faceSemi_bold); String url = ""; if (chatRecipientUrl.contains("http")) { url = chatRecipientUrl; } else { url = this.getResources().getString(R.string.url) + "/" + chatRecipientUrl; } addAndroidUniversalImageLoader(imgViewProfile, url); // if (noti && (!message.equals(""))) { // adapter.add(new StikyChat(chatRecipientUrl, message, true, timeSend, "")); // lv.smoothScrollToPosition(adapter.getCount() - 1); // } //to show history chats between two users(sender & recipient) dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat2 = new SimpleDateFormat("dd MMM HH:mm"); listHistory = dbHelper.getStikyChat(); if (listHistory.size() > 0) { Collections.reverse(listHistory); for (StikyChatTb chatTb : listHistory) { String getDate = chatTb.getSendDate(); String fromStikyBee = chatTb.getSender(); try { String createDate = dateFormat2.format(dateFormat.parse(getDate)); if (fromStikyBee.equals(pref.getString("stkid", ""))) { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), false, createDate, "")); } else { adapter.add(new StikyChat(chatRecipientUrl, chatTb.getMessage(), true, createDate, "")); } lv.smoothScrollToPosition(adapter.getCount() - 1); } catch (ParseException e) { e.printStackTrace(); } } } mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); messageGCM = sharedPreferences.getString("message", ""); recipientProfileGCM = sharedPreferences.getString("chatRecipientUrl", ""); recipientNameGCM = sharedPreferences.getString("chatRecipientName", ""); recipientStkidGCM = sharedPreferences.getString("recipientStkid", ""); recipientTokenGCM = sharedPreferences.getString("recipientToken", ""); senderTokenGCM = sharedPreferences.getString("senderToken", ""); Log.i(TAG, "..." + recipientStkidGCM.trim() + " STKID " + recipientStkid.trim() + ":"); if (firstConnect) { if (recipientStkidGCM.trim() == recipientStkid.trim() || recipientStkidGCM.equals(recipientStkid)) { MyGcmListenerService.flagSendNoti = false; Log.i(TAG, " " + message); // (1) get today's date start = new Date(); SimpleDateFormat oFormat = new SimpleDateFormat("dd MMM HH:mm"); timeSend = oFormat.format(start); Log.i(TAG, "First connect " + firstConnect); StikyChat stikyChat = new StikyChat(recipientProfileGCM, messageGCM, true, timeSend, ""); Log.i(TAG, " First " + message + " " + recipientProfileGCM + " " + timeSend); Log.i(TAG, "User " + txtUserName.getText().toString()); //txtUserName.setText(message); Log.i(TAG, "User 2 " + txtUserName.getText().toString()); adapter.add(stikyChat); adapter.notifyDataSetChanged(); //new regTask2().execute("Obj "); lv.smoothScrollToPosition(adapter.getCount() - 1); } else { Log.i(TAG, "..." + recipientStkidGCM.trim()); Log.i(TAG, "&&&" + recipientStkid.trim()); Log.i(TAG, "else casee"); //notificaton send flagNotifi = true; new regTask2().execute("Notification"); } firstConnect = false; } } }; }
From source file:com.moonpi.swiftnotes.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); TextView actionBarTitleView = null; if (actionBarTitle != 0) actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { if (lobsterTwo != null) actionBarTitleView.setTypeface(lobsterTwo); }// ww w.j a v a 2 s .co m readFromJSON(); writeToJSON(); readFromJSON(); File folder = new File(Environment.getExternalStorageDirectory() + "/Swiftnotes"); File backupFile = new File(folder, "swiftnotes_backup.json"); if (backupFile.exists()) backupFilePath = backupFile.getAbsolutePath(); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.listView); ImageButton newNote = (ImageButton) findViewById(R.id.newNote); noNotes = (TextView) findViewById(R.id.noNotes); // Initialize NoteAdapter with notes array adapter = new NoteAdapter(this, notes); registerForContextMenu(listView); listView.setAdapter(adapter); listView.setOnItemClickListener(this); newNote.setOnClickListener(this); // If no notes, show 'Press + to add new note' text, invisible otherwise if (notes.length() == 0) noNotes.setVisibility(View.VISIBLE); else noNotes.setVisibility(View.INVISIBLE); }
From source file:be.digitalia.fosdem.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;//from w ww. ja va 2 s . c o m TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { tabView.setSelected(true); } } }
From source file:com.farmerbb.notepad.adapter.NoteListDateAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); String date = item.getDate(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false); // Lookup view for data population TextView noteTitle = convertView.findViewById(R.id.noteTitle); TextView noteDate = convertView.findViewById(R.id.noteDate); // Populate the data into the template view using the data object noteTitle.setText(note);/*from w ww .j av a 2 s . com*/ noteDate.setText(date); // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary)); } if (theme.contains("dark")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark)); } if (theme.contains("sans")) { noteTitle.setTypeface(Typeface.SANS_SERIF); noteDate.setTypeface(Typeface.SANS_SERIF); } if (theme.contains("serif")) { noteTitle.setTypeface(Typeface.SERIF); noteDate.setTypeface(Typeface.SERIF); } if (theme.contains("monospace")) { noteTitle.setTypeface(Typeface.MONOSPACE); noteDate.setTypeface(Typeface.MONOSPACE); } switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); noteDate.setTextSize(8); break; case "small": noteTitle.setTextSize(14); noteDate.setTextSize(10); break; case "normal": noteTitle.setTextSize(16); noteDate.setTextSize(12); break; case "large": noteTitle.setTextSize(18); noteDate.setTextSize(14); break; case "largest": noteTitle.setTextSize(20); noteDate.setTextSize(16); break; } // Return the completed view to render on screen return convertView; }
From source file:at.linuxtage.companion.widgets.SlidingTabLayout.java
private void populateTabStrip() { final int adapterCount = mAdapter.getCount(); final View.OnClickListener tabClickListener = new TabClickListener(); final LayoutInflater inflater = LayoutInflater.from(getContext()); final int currentItem = mViewPager.getCurrentItem(); for (int i = 0; i < adapterCount; i++) { View tabView;/*w ww .ja va2 s.c o m*/ TextView tabTitleView; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = inflater.inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = tabView.findViewById(mTabViewTextViewId); if (tabTitleView == null) { tabTitleView = (TextView) tabView; } } else { // Inflate our default tab layout tabView = inflater.inflate(R.layout.widget_sliding_tab_layout_text, mTabStrip, false); tabTitleView = (TextView) tabView; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // Emulate Roboto Medium in previous Android versions tabTitleView.setTypeface(Typeface.DEFAULT_BOLD); } } if (mTextColor != null) { tabTitleView.setTextColor(mTextColor); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(mAdapter.getPageTitle(i)); tabView.setFocusable(true); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == currentItem) { setSelectedCompat(tabView, true); } } }
From source file:com.anjalimacwan.adapter.NoteListDateAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); String date = item.getDate(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false); // Lookup view for data population TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle); TextView noteDate = (TextView) convertView.findViewById(R.id.noteDate); // Populate the data into the template view using the data object noteTitle.setText(note);/*w w w. ja v a 2 s . co m*/ noteDate.setText(date); // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary)); } if (theme.contains("dark")) { noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark)); } if (theme.contains("sans")) { noteTitle.setTypeface(Typeface.SANS_SERIF); noteDate.setTypeface(Typeface.SANS_SERIF); } if (theme.contains("serif")) { noteTitle.setTypeface(Typeface.SERIF); noteDate.setTypeface(Typeface.SERIF); } if (theme.contains("monospace")) { noteTitle.setTypeface(Typeface.MONOSPACE); noteDate.setTypeface(Typeface.MONOSPACE); } switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); noteDate.setTextSize(8); break; case "small": noteTitle.setTextSize(14); noteDate.setTextSize(10); break; case "normal": noteTitle.setTextSize(16); noteDate.setTextSize(12); break; case "large": noteTitle.setTextSize(18); noteDate.setTextSize(14); break; case "largest": noteTitle.setTextSize(20); noteDate.setTextSize(16); break; } // Return the completed view to render on screen return convertView; }