size

Java, BorderLayout.CENTER, getting the width and height of the JPanel

一个人想着一个人 提交于 2019-12-12 09:42:45
问题 I am using Swing and AWT (for the listeners) to make a small program. I have a problem concerning getting the size of my JPanel (the class named Chess). My Layout: public class Main extends JFrame implements MouseListener, ActionListener{ Chess chessPanel = new Chess (); JButton newGameButton = new JButton ("New Game"); JButton loadGameButton = new JButton ("Load Game"); JButton saveGameButton = new JButton ("Save Game"); JButton exitButton = new JButton ("Exit"); public static void main

How to automatically adjust the TextView height according to the size of the String?

给你一囗甜甜゛ 提交于 2019-12-12 09:41:14
问题 I want to know how to automatically adjust the size of the TextView according to the length of the String . I am getting some data from another Intent as a String and storing it in a TextView . If I leave it small, the whole text won't fit and only half of it is displayed. If I leave a big space for the TextView it does not look nice on the screen. The solution I found online was using extends TextView and using this method gives errors in my class and I have to change a lot of functions

How to get size of a custom dialog in android?

我怕爱的太早我们不能终老 提交于 2019-12-12 08:38:20
问题 I have a custom Dialog which is extended from dialog. in order to place component on it, I need to know the width of the dialog. how could I do it? Thanks EDIT: public class AnswerTypeDialog extends Dialog{ public AnswerTypeDialog(Context context) { super(context); mContext = context; } @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); init(); } protected void init(){ ll=(RelativeLayout) LayoutInflater.from(mContext).inflate(R.layout

Android Spinner Size very large

心不动则不痛 提交于 2019-12-12 08:29:39
问题 I'm trying to get an ICS spinner like in my app, and playing around for hours, finally I'm using HoloEverywhere to get this, and it's working, but I have a little disign issue, is that the spinner is not wrapping its content as I set in the xml, and by default looks like this : Really I googled this for hours, and all I found is that how to resize spinner items and not the view itself, means that I want the spinner to be adjusted to the selected item size like this : Here is my XML:

How to get the length of dynamically allocated two dimensional arrays in C

两盒软妹~` 提交于 2019-12-12 08:11:30
问题 The question is how to get the length of dynamically allocated 2D Arrays in C? I thought the code below should get the number of rows, but it doesn't. char** lines; /* memory allocation and data manipulation */ int length; //the number of rows length = sizeof(lines)/sizeof(char*); Any thoughts on this? 回答1: You can't get the length of dynamically allocated arrays in C (2D or otherwise). If you need that information save it to a variable (or at least a way to calculate it) when the memory is

Set width of Button in Android

北慕城南 提交于 2019-12-12 07:44:15
问题 How can I set a fixed width for an Android button? Everytime I try to set a fixed width it fills the current parent (the RelativeView). Here is my XML: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/relativelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <EditText android:layout_height="wrap_content" android:editable="false" android:layout_width="fill_parent" android:id="@+id

How do I get android paint(stylus) size?

拟墨画扇 提交于 2019-12-12 06:29:34
问题 I am developing an App that need to detect the stylus's size, for instance, if I use my hand(relatively wide) to draw, return null, if I use the stylus(relatively small) to draw, execute draw.Point method. I have no idea how to detect this. Please for help thanks. My code list as below. public PaintView(Context context) { super(context); paint=new Paint(Paint.DITHER_FLAG); bitmap = Bitmap.createBitmap(MainActivity.widthPixels, MainActivity.heightPixels, Bitmap.Config.ARGB_8888); canvas=new

calculating the real size of a python string

十年热恋 提交于 2019-12-12 06:26:04
问题 First of all this is my computer Spec : Memory - https://gist.github.com/vyscond/6425304 CPU - https://gist.github.com/vyscond/6425322 So this morning I've tested the following 2 code snippets: code A a = 'a' * 1000000000 and code B a = 'a' * 10000000000 The code A works fine. But the code B give me some error message : Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError So I started a researching about method to measuring the size of data on python. The first

Android with DownloadManager get total file size

浪尽此生 提交于 2019-12-12 05:42:03
问题 I have researched every where but no any solution. I have a snippet code that run and get the total file size normally while in debug mode of eclipse. But when i run the project the value of sizeOfDownloadingFile only return -1. Please help me, I compile with Android 22, thanks in advance. long id = downloadManager.enqueue(request); Cursor cursor = downloadManager.query(new DownloadManager.Query() .setFilterById(id)); if (!cursor.moveToFirst()) { Log.v("DownloadManagerService", "download list

defining an array size without hardcoding in Java

大城市里の小女人 提交于 2019-12-12 05:17:06
问题 I'm having a problem where I cannot initialize an array without hard-coding it in Java. So this is the hard-code version which works: int numberOfElements = inputFromFile(args[0], myArray); int [] myArray = new int[1000]; inputFromFile is basically going to be a method I'm going to write that can read the numberOfElements from a textfile along with my program. I tried fixing it without hardcoding and got my result to be this: int numberOfElements = inputFromFile(args[0], myArray); int []