package com.example.users;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class Act2 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_act2);
OnClickListener btn_events = new OnClickListener() {
@SuppressLint("NewApi") @Override
public void onClick(View v)
{
ImageView img = (ImageView)findViewById(R.id.imageView2);
int l = img.getLeft();
int t = img.getTop();
int r = img.getRight();
int b = img.getBottom();
switch (v.getId())
{
case R.id.button1:
t--;
l--;
break;
case R.id.button3:
t--;
l++;
break;
case R.id.button4:
t++;
l--;
break;
case R.id.button5:
t++;
l++;
break;
case R.id.button2:
Notification.Builder m = new Notification.Builder(Act2.this);
m.setSmallIcon(R.drawable.p2);
m.setContentTitle("Arslanbar");
//m.setOngoing(true);
m.setContentText("The app is under construction.");
NotificationManager nm = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancelAll();
nm.notify(1, m.build());
break;
}
img.layout(l, t, r, b);
}
};
findViewById(R.id.button1).setOnClickListener(btn_events);
findViewById(R.id.button2).setOnClickListener(btn_events);
findViewById(R.id.button3).setOnClickListener(btn_events);
findViewById(R.id.button4).setOnClickListener(btn_events);
findViewById(R.id.button5).setOnClickListener(btn_events);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.act2, menu);
return true;
}
}