It is required that when selecting the context menu for the selected city, a link to Glide is inserted (additional library for displaying hyphae). The context menu when a long tap is called, but then after selecting from the list it does not go.
Ideally, I would like the button to call up a list on the screen and select a city, but so far only the context menu could call up and make a list in it.
Here are my ideas:
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.ContextMenu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; public class MainActivity extends AppCompatActivity { private ImageView ImageView; private Button getRadar; private TextView city; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getRadar = (Button) findViewById(R.id.getRadar); ImageView = (ImageView) findViewById(R.id.ImageView); city = (TextView) findViewById(R.id.city); registerForContextMenu(city); } final int brest = 1; final int moskva = 2; final int minsk = 3; @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { switch (v.getId()) { case R.id.city: menu.add(0, brest, 0, "BREST"); menu.add(0, moskva, 0, "MOSKOW"); menu.add(0, minsk, 0, "MINSK"); break; } } public boolean onContextItemSelected(MenuItem item) { switch (item.getItemId()) { case brest: Glide.with(this).load("http://site.ru/1.gif").asGif().into(ImageView); break; case moskva: Glide.with(this).load("http://site.ru/2.gif").asGif().into(ImageView); break; case minsk: Glide.with(this).load("http://site.ru/3.gif").asGif().into(ImageView); break; } return super.onContextItemSelected(item); }
Spinneras a selector. The names of class instances are usually written in small lettersImageView imageView;(in lowCamelCase style) / Resource names are also usually written with a small letterR.id.imageView- pavlofffSpinneryesterday, yes, it’s convenient, but I didn’t manage to pass the link to the city in Glide. Could you give me even the simplest example of how this is implemented? - Pollux