小编Joh*_*son的帖子

将消息发送到唯一的套接字

我正在使用node.js和socket.io来创建聊天应用程序.如何将消息发送到另一个套接字,我只知道套接字的id或用户名.没有房间,客户一对一聊天.

chat node.js socket.io

9
推荐指数
1
解决办法
8370
查看次数

如何访问TableLayout中的视图

在3x3格式中TableLayout有9 Buttons个.如何使用TableLayout(不是按钮ID)的id以编程方式访问这些按钮上的文本?

android button tablelayout

7
推荐指数
2
解决办法
1万
查看次数

无法在JPanel上设置JLabel的位置

我已经为JLabel设置了相对于JPanel的位置(0,0).但它正在中心和顶部.我犯了什么错误?

import java.awt.*; 
import javax.swing.*; 
import java.awt.event.*;
public class Main extends JFrame 
{ 
private JPanel panel;
private JLabel label1;
public Main() 
{ 
    panel = new JPanel(); 
    panel.setBackground(Color.YELLOW); 

    ImageIcon icon1 = new ImageIcon("3.png"); 
    label1 = new JLabel(icon1); 
    label1.setLocation(0,0); 
    panel.add(label1);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.getContentPane().add(panel); 
    this.setSize(500,500); 
    this.setVisible(true); 

} 

public static void main (String[] args) {
    new Main(); 
} 
} 
Run Code Online (Sandbox Code Playgroud)

java swing jlabel jpanel

6
推荐指数
2
解决办法
3万
查看次数

如何获取其名称在Javascript中已知的元素的id

我知道HTML元素的名称,但不知道id.如何使用Javascript使用元素的名称获取id.请帮助.

html javascript getelementsbyname

5
推荐指数
2
解决办法
4万
查看次数

在`ImageAdapter中设置自定义字体扩展了BaseAdapter`

ImageAdapter extends BaseAdapter用来膨胀一个gridview.Gridview有两个textview.我想为其中一个设置自定义字体.使用Typeface font = Typeface.createFromAsset(getAssets(), "BABYCAKE.TTF");in ImageAdapter会出错The method getAssets() is undefined for the type ImageAdapter.

ImageAdapter 被定义为

package com.amit.wozzle;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.LayoutInflater;

public class ImageAdapter extends BaseAdapter
{  
private ArrayList<String> listCountry;  
private ArrayList<String> scorestage;  
private Activity activity;  
Typeface font;

public ImageAdapter(Activity activity,ArrayList<String> listCountry, ArrayList<String> scorestage) …
Run Code Online (Sandbox Code Playgroud)

fonts android gridview adapter

4
推荐指数
1
解决办法
4150
查看次数

在android应用程序中设置自定义字体

是否可以一次性为整个Android应用程序设置自定义字体.我的意思是我不想setTypeFace在每个活动中使用每个textview.不仅是文本视图,还有每个可能的文本.

android custom-font

3
推荐指数
1
解决办法
276
查看次数

ViewFlipper高度问题

在下面的代码中,它viewflipper并没有占据整个屏幕,它只是围绕着textview. 为什么会发生这种情况?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView  
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#0000ff" >

        <ViewFlipper android:id="@+id/ViewFlipper01"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#aa0000"
            android:layout_gravity="center">  

            <TextView
                android:layout_width="match_parent"
                android:layout_height="50dp"></TextView>

        </ViewFlipper>
    </ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

layout android viewflipper

3
推荐指数
1
解决办法
2012
查看次数

ImageIcon未显示

我正在尝试显示类主教的对象的ImageIcon.使用getImage()检索ImageIcon.返回的ImageIcon存储在引用m中但它没有显示,并且正在显示另一个直接加载的ImageIcon h.我犯了什么错误?

import javax.swing.*;

//Game.java

public class Game {

    public static void main(String[] args) {
        board b = new board();
        bishop bis1 = new bishop();
        bis1.setLocation(0, 0);
        ImageIcon m = bis1.getImage();
        b.squares[0][1].add(new JLabel(m));
        ImageIcon h = new ImageIcon("rook.png");
        b.squares[0][0].add(new JLabel(h));
    }
}

//bishop.java
import javax.swing.*;
import java.awt.*;

public class bishop {
    private ImageIcon img;
    private int row;
    private int col;

    public void bishop() {
        img = new ImageIcon("bishop.png");
    }

    public void setLocation(int i, int j) {
        row = i;
        col …
Run Code Online (Sandbox Code Playgroud)

java swing imageicon

0
推荐指数
1
解决办法
1522
查看次数

C#中的多维数组中的问题

这是将一个2D数组的所有值分配给另一个2D数组的有效方法吗?

matrix1=matrix2;
Run Code Online (Sandbox Code Playgroud)

它们都是mXn维度.

.net c#

-2
推荐指数
1
解决办法
81
查看次数