I was having some problem when trying to dim the background of Activity without dialog for a few seconds.
So what I am trying to do is when button on click, it will dim the background for a few seconds. Then at the same time, my another intent is loading up the content. Once the content finished loaded, the it will shift to another page. Here is the codes:
ivTwitterShare.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
WindowManager.LayoutParams windowManager = getWindow().getAttributes();
windowManager.dimAmount = 0.75f;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
// Create intent using ACTION_VIEW and a normal Twitter url
tweetUrl = String
.format("",
urlEncode("Come join us for "
+ txtEventDtlName.getText().toString()),
urlEncode("at "
+ txtEventDtlAddr.getText().toString()
+ " on "
+ txtEventDtlDate.getText().toString()));
Thread newThread = new Thread() {
@Override
public void run() {
try {
super.run();
sleep(10000);
} catch (Exception e) {
} finally {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri
.parse(tweetUrl));
// Narrow down to official Twitter app
startActivity(intent); }
}
};
newThread.start();
}
});
However, I am getting error message at the getWindow(): The method getWindow() is undefined for the type new View.OnClickListener(){}
Any ideas? Thanks in advance.