私はJavaを初めて使っています。 バックグラウンドリソースを設定した後、私の写真を "表示"するには "FLASH"ボタンが必要です。現在はスキップしています。コードの最後に "off"値に変わります。私がオンラインで見つける方法のリフレッシュレイアウトをjava/androidの描画可能な値に強制する方法
私が試してみました:無駄に
FLASH.invalidate;
----
ViewGroup vg = (ViewGroup) findViewById(R.id.parent);
vg.invalidate;
----
//setting FLASH as a togglebutton, with an xml file in drawable, which works when clicked
FLASH.setChecked(true);
----
FLASH.jumpDrawablesToCurrentState();
----
ViewGroup vg = (ViewGroup) findViewById(R.id.parent);
vg.jumpDrawablesToCurrentState();
----
FLASH.performClick;
----
//making giant loops and functions with if's or different calls to functions so it could refresh at the end of it
すべて
package net.myfreesites.httpmatthigast.test;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
//import android.view.ViewGroup;
import android.widget.Button;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onStart()
{
super.onStart();
game();
}
public void game()
{
final Button GO;
GO = (Button) findViewById(R.id.Start);
GO.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Button FLASH;
FLASH = (Button) findViewById(R.id.Flash);
try
{
FLASH.setBackgroundResource(R.drawable.on);
//Here I need something that forces the image "on" onto my FLASH-Button
Thread.sleep(500);
FLASH.setBackgroundResource(R.drawable.off);
Thread.sleep(500);
}
catch (InterruptedException ignored)
{
}
}
});
}
}
私は後にこの一つのフラッシュを作ることができる場合(これは、私のゲームのコードが、単一のボタンではありませんがGO-ボタンをクリックすると、私は(私のゲーム全体のポイントである)私のゲームのフラッシュでものを作ることができます)事前に
感謝:)
は、以下の私の答えを参照してください、あなたの問題が何であるかをもっと説明してください、私は、半分理解した上で、これを答えることができます願っています。 – anddevmanu