batch = new SpriteBatch();
stage = new Stage(800, 480, false);
Gdx.input.setInputProcessor(stage);
tex = new Texture(Gdx.files.internal("data/button.png"));
TextureRegion region_up = new TextureRegion(tex, 0, 0, 210, 60);
TextureRegion region_down = new TextureRegion(tex, 210,0,210,60);
TextureRegionDrawable up = new TextureRegionDrawable(region_up);
TextureRegionDrawable down = new TextureRegionDrawable(region_down);
button = new ImageButton(up, down);
button.addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y,
int pointer, int button) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL url;
try {
url = new URL("http://192.168.2.210:8080/photo/mao.jpg");
URLConnection conn = url.openConnection();
conn.connect();
final InputStream is=conn.getInputStream();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
ture = new Texture(new FileHandle("image.jpg") {
@Override
public InputStream read () {
return is;
}
});
Texture.setEnforcePotImages(false);
}
});
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
//
HttpRequest httpRequest = new HttpRequest(Net.HttpMethods.GET);
//
httpRequest.setUrl("http://192.168.2.210:8080/photo/mao.jpg");
//
httpRequest.setTimeOut(800000);
//
Gdx.net.sendHttpRequest(httpRequest, MyGame.this);