Android Popup Window
Android
2
Posts
2
Posters
0
Views
1
Watching
-
I have created app that detects otg cable using service. I have created button in action bar with icon,how to make if otg cable is connected hide that button if not connected it should show text and when clicked on it to get popup window with text and animation? MainActivity.class
public class MainActivity extends AppCompatActivity
{public void startOtgService() { startService(new Intent(MainActivity.this, OtgService.class)); } public void stopOtgService() { stopService(new Intent(MainActivity.this, OtgService.class)); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity\_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH\_LONG) .setAction("Action", null).show(); } }); Button startButton = (Button)this.findViewById(R.id.startButton); Button stopButton = (Button)this.findViewById(R.id.stopButton); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startOtgService(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopOtgService(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu\_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action\_set
-
I have created app that detects otg cable using service. I have created button in action bar with icon,how to make if otg cable is connected hide that button if not connected it should show text and when clicked on it to get popup window with text and animation? MainActivity.class
public class MainActivity extends AppCompatActivity
{public void startOtgService() { startService(new Intent(MainActivity.this, OtgService.class)); } public void stopOtgService() { stopService(new Intent(MainActivity.this, OtgService.class)); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity\_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH\_LONG) .setAction("Action", null).show(); } }); Button startButton = (Button)this.findViewById(R.id.startButton); Button stopButton = (Button)this.findViewById(R.id.stopButton); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startOtgService(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { stopOtgService(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu\_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action\_set
read this artice Android Alert Dialog with Fragments - Andro Development[^]