我正在尝试TextView从代码中更改我的文本.
这就是我的xml的样子:
XML:
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" />
Run Code Online (Sandbox Code Playgroud)
和代码:
TextView tv1 = (TextView)findViewById(R.id.textView1);
tv1.setText("Hello");
setContentView(tv1);
Run Code Online (Sandbox Code Playgroud)
我的设备出现错误,应用程序停止运行.我试图显示一个TextView(没有连接到XML TextView),它工作.
我创建了一个没有标题栏的框架,因为我使用了setUndecorated(true); 方法但之后,由于某种原因,框架变得不可移动.
如何让我的框架移动并仍隐藏我的标题栏?
我有一个包含4个字段的表:
id,int(11),auto increament email,varchar(32)pass,varchar(32)date_created,date
我的问题是我的查询应该是什么样的?我的意思是我不需要将第一个值插入id,因为它是自动增量但我必须插入所有的值..
我知道将dll转换为c ++代码是不可能的,所以我想从中收集尽可能多的细节.这不是我的dll,所以我当然没有源代码.我应该使用哪个程序?
我正在尝试将希伯来语值插入到我的mysql数据库中,而不是希伯来语中的值看起来像那样.
ש×"×'ש×"×>עש×"
该表的排序规则是latin1_swedish_ci默认情况下,我也尝试更改为utf-8_general_ci,hebrew_bin,hebrew_general_ci,但结果仍然相同.
在我的代码中,我当然使用元标记来配置字符集:
<meta charset="UTF-8">
Run Code Online (Sandbox Code Playgroud)
在我的php查询之前,我添加了这一行:
mysql_query("SET NAMES utf8");
Run Code Online (Sandbox Code Playgroud)
我在phpmyadmin中查看结果.
我想添加ActionListener一组按钮.是否有任何类包裹按钮?喜欢GroupJButtons什么东西或更普遍的东西?所以我可以设置ActionListener所有这些.毕竟我并不关心按哪个按钮我只想更改他的文本所以我需要做的就是将它转换为JButton更改文本.
整个过程会减少1或2中的代码行(如果你使用循环)但我想这样做,因为它听起来逻辑上更好.
我想在以下代码中使用ArrayList而不是数组:
for(int k=0;k<SIZE;k++) //size is 9
for(int j=0;j<SIZE;j++)
ar1[k][j] = buttons[k][j].getText();
Run Code Online (Sandbox Code Playgroud)
这就是我猜测ArrayList的样子:
ArrayList<ArrayList<String>>ar1 = new ArrayList<ArrayList<String>>();
Run Code Online (Sandbox Code Playgroud)
但是由于我不能使用get方法,所以令人困惑.我不知道该怎么做.
我正在尝试通过gps提供程序首先生成一个位置,如果我得到一个null,我正在通过网络提供程序生成.我的问题是网络提供商两次生成相同的位置..我将信息发送到数据库,并在同一时间发送相同的位置(相同的秒数!).这是一些代码:
gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
networkLocation = requestUpdatesFromProvider(LocationManager.NETWORK_PROVIDER, R.string.not_support_gps);
// Update the UI immediately if a location is obtained.
if (gpsLocation != null)
updateUILocation(gpsLocation);
else
updateUILocation(networkLocation);
Run Code Online (Sandbox Code Playgroud)
这是requestUpdateFromProvider:
private Location requestUpdatesFromProvider(final String provider, final int errorResId)
{
Location location = null;
if (mLocationManager.isProviderEnabled(provider))
{
mLocationManager.requestLocationUpdates(provider, TEN_SECONDS, TEN_METERS*2, listener);
location = mLocationManager.getLastKnownLocation(provider);
}
else
{
Toast.makeText(this, errorResId, Toast.LENGTH_LONG).show();
}
return location;
}
Run Code Online (Sandbox Code Playgroud)
这是updateUILocation:
private void updateUILocation(Location location)
{
// We're sending the update to a handler which then updates the UI with …Run Code Online (Sandbox Code Playgroud) 我试图通过在C++中使用内联汇编来增加数值.我这样做的原因是练习我的"内联汇编"技能.
那就是我到目前为止所做的事情:
void main()
{
int x;
cout << "Please enter a number ";
cin >> x;
cout << "The number you entered is: " << x << "\n";
foo(&x);
cout << "The new number is: " << x;
cin >> x;
}
void foo(int *x)
{
__asm
{
inc [x]
};
}
Run Code Online (Sandbox Code Playgroud)
价值从未改变.
我正在尝试制作一个由9x9 JButton制作的简单的tic tac toe board.我使用了二维数组和一个gridlayout,但结果是什么,没有任何按钮的框架.我做错了什么?
import java.awt.GridLayout;
import javax.swing.*;
public class Main extends JFrame
{
private JPanel panel;
private JButton[][]buttons;
private final int SIZE = 9;
private GridLayout experimentLayout;
public Main()
{
super("Tic Tac Toe");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,500);
setResizable(false);
setLocationRelativeTo(null);
experimentLayout = new GridLayout(SIZE,SIZE);
panel = new JPanel();
panel.setLayout(experimentLayout);
buttons = new JButton[SIZE][SIZE];
addButtons();
add(panel);
setVisible(true);
}
public void addButtons()
{
for(int k=0;k<SIZE;k++)
for(int j=0;j<SIZE;j++)
{
buttons[k][j] = new JButton(k+1+", "+(j+1));
experimentLayout.addLayoutComponent("testName", buttons[k][j]);
}
}
public static void main(String[] args)
{ …Run Code Online (Sandbox Code Playgroud)