Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Android Popup Window

Android Popup Window

Scheduled Pinned Locked Moved Android
androidxmltutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pavlex4
    wrote on last edited by
    #1

    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
    
    A 1 Reply Last reply
    0
    • P Pavlex4

      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
      
      A Offline
      A Offline
      Andro Development
      wrote on last edited by
      #2

      read this artice Android Alert Dialog with Fragments - Andro Development[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups