setbackground

change color of item in listview (without click)

99封情书 提交于 2019-12-08 10:26:11
问题 I've tried to change the background color of specific items in a ListView . first, catch it from database: ListAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, db.getAllApps()); final ListView list = (ListView) findViewById(R.id.ListViewApps); list.setAdapter(adapter); then I will set all apps in different color, if they have the tag activated // if app is activated in db --> set another colour in ListView private void setAppCheck(ListView list)

Why does setBackground to JButton does not work?

雨燕双飞 提交于 2019-12-03 18:08:14
问题 I have the following simple code: btn = new JButton(); btn.setBackground(backgroundColor) I worked when I used: UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); But it stopped to work after I have commented the above line. Does anybody know why it can happen and how I can set a background color to a button without the usage of an explicit Look and Feel? ADDED It seems to me that I need to use getBackground . But I do not know how. 回答1: it is necessary to

JPanel setBackground(Color.BLACK) does nothing

a 夏天 提交于 2019-12-01 03:33:50
I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won't change! I can see the circle, drawing with g.fillOval(). What's wrong? public class Board extends JPanel{ private Player player; public Board(){ setOpaque(false); setBackground(Color.BLACK); } public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.red); g.fillOval(player.getxCenter(), player.getyCenter(), player.getRadius(), player.getRadius()); } public void updatePlayer(Player player){ this.player=player; } } If your panel is 'not opaque'

JPanel setBackground(Color.BLACK) does nothing

独自空忆成欢 提交于 2019-12-01 01:03:18
问题 I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won't change! I can see the circle, drawing with g.fillOval(). What's wrong? public class Board extends JPanel{ private Player player; public Board(){ setOpaque(false); setBackground(Color.BLACK); } public void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(Color.red); g.fillOval(player.getxCenter(), player.getyCenter(), player.getRadius(), player.getRadius()); }

Android View background changes unexpectedly

那年仲夏 提交于 2019-11-30 17:22:52
I'm building an app that has plenty of screens. most of the screens have a View at the top with a background color. I often change that color using view.setBackgroundColor(color) Here comes the weird thing: sometimes after setting the color of one view, say to #f14fb7 , when navigating in the app, other views' backgrounds are set to that color without me wanting them to. It sometimes even happens to views I had not set an id for, so there is no way setBackgroundColor was called on those views. This happens rarely and is not consistant to any flow I tried. When I kill the app and restart it,

Android View background changes unexpectedly

人盡茶涼 提交于 2019-11-30 16:37:10
问题 I'm building an app that has plenty of screens. most of the screens have a View at the top with a background color. I often change that color using view.setBackgroundColor(color) Here comes the weird thing: sometimes after setting the color of one view, say to #f14fb7 , when navigating in the app, other views' backgrounds are set to that color without me wanting them to. It sometimes even happens to views I had not set an id for, so there is no way setBackgroundColor was called on those views

set cornerRadius and setbackgroundimage to UIButton

我只是一个虾纸丫 提交于 2019-11-29 21:15:56
I am trying to set cornerRadius of UIButton but I dont know how to do it. If I do like this: button.layer.cornerRadius = 5; works well, if I do like this : button.layer.cornerRadius = 5; [button setBackgroundColor:[UIColor colorWithPatternImage:radialGradient]]; the corners are not rounded. I know I could solve this whit [button.layer setMasksToBounds:YES]; but I specifically looking for different solution, because I add some arrows to the button and if I set mask to bounds the arrow are masked. EDIT : radialGradient is made whit func + (UIImage *)getRadialGradientImage:(CGSize)size centre:

Android setBackgroundTintList on pre-lollipop devices

十年热恋 提交于 2019-11-29 02:20:45
问题 I'm working with FloatingActionButton . The user should be able to switch the FAB background color within a onClick Event. However, the recommended call to setBackgroundTintList seems to be only compatible from 21+ API. How do I - correctly - go about it on pre-lollipop devices? Is there any alternative I could use? Thanks in advance. 回答1: You can use also setSupportBackgroundTintList Applies a tint to the background drawable. Does not modify the current tint mode, which is SRC_IN by default.

Change background color editable JComboBox

拈花ヽ惹草 提交于 2019-11-27 23:20:03
I am programming an editable combobox in a JFrame Form, but i want to change te background color. How the program works: If i click the button "press", then the combobox his background needs to become black. I tried: 1. cbo.setBackground(Color.BLACK); But it did nothing 2 cbo.getEditor().getEditorComponent().setBackground(Color.BLACK); ((JTextField) cbo.getEditor().getEditorComponent()).setOpaque(true); Does this: Code example: public class NewJFrame extends javax.swing.JFrame { private JComboBox cboCategorie; public NewJFrame() { initComponents(); cboCategorie = new JComboBox(); cboCategorie

How to solve java.lang.OutOfMemoryError trouble in Android

我们两清 提交于 2019-11-25 23:53:53
问题 Altough I have very small size image in drawable folder, I am getting this error from users. And I am not using any bitmap function in code. At least intentionally :) java.lang.OutOfMemoryError at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889) at