我正在尝试以编程方式更改ImageButton的图像.
我正在尝试复制此代码,但已弃用setBackgroundDrawable.
public void giveClue(View view) {
Drawable replacer = getResources().getDrawable(R.drawable.icon2);
((ImageButton) view).setEnabled(false);
((ImageButton) view).setBackgroundDrawable(replacer);
gameAdapter.giveClue(game);
}
Run Code Online (Sandbox Code Playgroud)
我的按钮是使用xml创建的,如下所示:
<ImageButton
android:id="@+id/ImageButton2"
android:layout_width="24dp"
android:layout_height="22dp"
android:layout_alignTop="@+id/imageButton1"
android:layout_toLeftOf="@+id/ImageButton3"
android:src="@drawable/icon"
android:onClick="giveClue"/>
Run Code Online (Sandbox Code Playgroud)
请帮忙.
谢谢.
好吧,我正在试图弄清楚如何从网页中提取信息,并将其带入我的程序(用Java).
例如,如果我知道我想要信息的确切页面,为了简单起见,Best Buy项目页面,我如何从该页面获得我需要的相应信息?喜欢标题,价格,描述?
这个过程甚至会被称为什么?我不知道甚至开始研究这个.
编辑:好的,我正在为JSoup(由BalusC发布的那个)运行测试,但我一直收到这个错误:
Exception in thread "main" java.lang.NoSuchMethodError: java.util.LinkedList.peekFirst()Ljava/lang/Object;
at org.jsoup.parser.TokenQueue.consumeWord(TokenQueue.java:209)
at org.jsoup.parser.Parser.parseStartTag(Parser.java:117)
at org.jsoup.parser.Parser.parse(Parser.java:76)
at org.jsoup.parser.Parser.parse(Parser.java:51)
at org.jsoup.Jsoup.parse(Jsoup.java:28)
at org.jsoup.Jsoup.parse(Jsoup.java:56)
at test.main(test.java:12)
Run Code Online (Sandbox Code Playgroud)
我有Apache Commons
我尝试使用Google Map制作示例项目,但我做不到.请帮帮我!
测试设备:Android 4.0.4
错误信息 :
12-29 23:45:32.605: E/AndroidRuntime(9437): FATAL EXCEPTION: main
12-29 23:45:32.605: E/AndroidRuntime(9437):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.test_googlemap/com.example.test_googlemap.MainActivity}:
android.view.InflateException: Binary XML file line #2: Error
inflating class fragment 12-29 23:45:32.605: E/AndroidRuntime(9437):
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1968)
12-29 23:45:32.605: E/AndroidRuntime(9437): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
12-29 23:45:32.605: E/AndroidRuntime(9437): at
android.app.ActivityThread.access$600(ActivityThread.java:127) 12-29
23:45:32.605: E/AndroidRuntime(9437): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
12-29 23:45:32.605: E/AndroidRuntime(9437): at
android.os.Handler.dispatchMessage(Handler.java:99) 12-29
23:45:32.605: E/AndroidRuntime(9437): at
android.os.Looper.loop(Looper.java:137) 12-29 23:45:32.605:
E/AndroidRuntime(9437): at
android.app.ActivityThread.main(ActivityThread.java:4507) 12-29
23:45:32.605: E/AndroidRuntime(9437): at
java.lang.reflect.Method.invokeNative(Native Method) 12-29
23:45:32.605: E/AndroidRuntime(9437): at
java.lang.reflect.Method.invoke(Method.java:511) 12-29 23:45:32.605:
E/AndroidRuntime(9437): at …Run Code Online (Sandbox Code Playgroud) 该文档指出,如果提供程序成功加载,我们应该返回true,否则返回false.在我的实现中,如果DatabaseHelper == null,我将返回false.
假设现在DatabaseHelper == null并且在onCreate中返回false,并且稍后在代码中的某处查询提供者,仍在查询提供者,因为它会崩溃.
我的问题是在ContentProvider的OnCreate中返回false的用途是什么?在onCreate失败后,我应该如何处理查询?在查询中再次运行onCreate?
我有这样的两倍ArrayList的java.
List<double[]> values = new ArrayList<double[]>(2);
Run Code Online (Sandbox Code Playgroud)
现在我想做的是通过循环在列表的零索引中添加5个值,在索引1中添加5个值.
第零个索引将具有值{100,100,100,100,100}
索引1将具有值{50,35,25,45,65}
并且所有这些值按以下顺序存储在双数组中
double[] values = {100,50,100,35,100,25,100,45,100,65}
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我正在使用带有一组项目的加载微调器动画.如果你点击它外面,它应该消失.有人知道怎么做这个吗?

我试过这个.它正在使用EditText.但它不起作用Spinner
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View view = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(event);
if (view instanceof EditText||view instanceof Spinner) {
View w = getCurrentFocus();
int scrcoords[] = new int[2];
w.getLocationOnScreen(scrcoords);
float x = event.getRawX() + w.getLeft() - scrcoords[0];
float y = event.getRawY() + w.getTop() - scrcoords[1];
if (event.getAction() == MotionEvent.ACTION_UP
&& (x < w.getLeft() || x >= w.getRight()
|| y < w.getTop() || y > w.getBottom()) ) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); …Run Code Online (Sandbox Code Playgroud) 我有PAC MAN游戏代码如何在Android中将此游戏称为活动..我想在Android应用程序中调用在线游戏,而不是如何在链接上调用Android应用程序中的在线游戏,如果用户点击该特定游戏链接,比游戏午餐形式网上网...像PAC MAN这样的游戏.谢谢
public class Board extends JPanel implements ActionListener {
Dimension d;
Font smallfont = new Font("Helvetica", Font.BOLD, 14);
FontMetrics fmsmall, fmlarge;
Image ii;
Color dotcolor = new Color(192, 192, 0);
Color mazecolor;
boolean ingame = false;
boolean dying = false;
final int blocksize = 24;
final int nrofblocks = 15;
final int scrsize = nrofblocks * blocksize;
final int pacanimdelay = 2;
final int pacmananimcount = 4;
final int maxghosts = 12;
final int pacmanspeed = 6;
int …Run Code Online (Sandbox Code Playgroud) 我试图在我的活动上显示水平进度条" Not ProgressDialog "

这是我的xml文件包含的内容
<ProgressBar
android:id="@+id/pdialog"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
/>
Run Code Online (Sandbox Code Playgroud)
我试图通过设置pdialog.setProgress()来使用AsyncTask类更新其状态,但它没有显示任何进度,它适用于progressdialog但不适用于水平进度条.
public class MainActivity extends Activity {
private SQLiteDatabase db;
private Cursor cursor;
private ProgressBar pdialog;
private ImageButton btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
btn = (ImageButton) findViewById(R.id.startbtn);
pbar = (ProgressBar) findViewById(R.id.progressBar1);
pdialog = (ProgressBar) findViewById(R.id.pdialog);
pdialog.setMax(100);
pdialog.setProgress(20);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pdialog.setVisibility(View.VISIBLE);
new DownloadFilesTask().execute();
}
});
}
private class DownloadFilesTask extends AsyncTask<Void, Integer, Integer> {
int load = 1; …Run Code Online (Sandbox Code Playgroud) 我正在制作一个Android程序.在我的应用程序中,我使用单选项AlertDialog,其项目以编程方式添加.我想做的是:
这就是我所拥有的:XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp" >
<Button
android:id="@+id/selectDateButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please, select date" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
JAVA:
public class ExperimentListView extends Activity {
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private static Calendar calendar = Calendar.getInstance();
private static Button selectDateButton;
private static String[] items;
private static int selectedDatePosition = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_view_ex);
selectDateButton = (Button)findViewById(R.id.selectDateButton);
selectDateButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View …Run Code Online (Sandbox Code Playgroud) android ×9
java ×2
arraylist ×1
dialog ×1
header ×1
html ×1
imagebutton ×1
jsoup ×1
progress-bar ×1
spinner ×1
views ×1
web-scraping ×1