精华内容
参与话题
问答
  • ContextMenu

    2011-06-07 15:15:00
    ContextMenu

    ContextMenu

    展开全文
  • Contextmenu

    2016-09-17 19:34:08
    import java.util.ArrayList; import android.app.Activity; import android.os.Bundle;...import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.MenuItem; impo
    <span style="font-size:18px;">import java.util.ArrayList;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.ContextMenu;
    import android.view.ContextMenu.ContextMenuInfo;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.AdapterView.AdapterContextMenuInfo;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    
    	private ListView listView;
    	private ArrayList<String> strList;
    	private ArrayAdapter<String> arrayAdapter;
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		listView = (ListView) findViewById(R.id.listView);
    		// 注册上下文菜单
    		this.registerForContextMenu(listView);
    
    		// 初始化数据
    		// 设置适配器
    		arrayAdapter = new ArrayAdapter<String>(this,
    				android.R.layout.simple_list_item_1, android.R.id.text1,
    				strList);
    		initData();
    		listView.setAdapter(arrayAdapter);
    	}
    
    	/**
    	 * 生成上下文菜单
    	 */
    	@Override
    	public void onCreateContextMenu(ContextMenu menu, View v,
    			ContextMenuInfo menuInfo) {
    		menu.add(0, 1, ContextMenu.NONE, "修改条目");
    		menu.add(0, 2, ContextMenu.NONE, "添加条目");
    		menu.add(0, 3, ContextMenu.NONE, "删除条目");
    		super.onCreateContextMenu(menu, v, menuInfo);
    	}
    	/**
    	 * 响应上下文菜单
    	 */
    	@Override
    	public boolean onContextItemSelected(MenuItem item) {
    		int id = item.getItemId();
    		// 获取当前长按条目的索引值
    		AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item
    				.getMenuInfo();
    		int position = menuInfo.position;
    		switch (id) {
    		case 1:
    			// Toast.makeText(this, "修改", 0).show();
    			// strList.add(position, "我是修改过的条目");
    			strList.remove(position);
    			strList.add(position, "我是修改过的条目");
    			// Toast.makeText(this, strList.get(position), 0).show();
    			// 刷新数据适配器
    			arrayAdapter.notifyDataSetChanged();
    			break;
    		case 2:
    			Toast.makeText(this, "添加", 0).show();
    			strList.add(position, "我是新添加的条目");
    			// 刷新适配器
    			arrayAdapter.notifyDataSetChanged();
    			break;
    		case 3:
    			strList.remove(position);
    			Toast.makeText(this, "删除", 0).show();
    			arrayAdapter.notifyDataSetChanged();
    			break;
    
    		default:
    			break;
    		}
    		return super.onContextItemSelected(item);
    	}
    	private void initData() {
    		strList = new ArrayList<String>();
    		for (int i = 0; i < 20; i++) {
    			strList.add("我是第" + i + "条目");
    		}
    	}
    
    }
    </span>

    展开全文
  • contextmenu

    2013-09-17 16:06:00
    void Loaded(object sender, RoutedEventArgs e) { ContextMenu contextMenu = new ContextMenu(); contextMenu.Background = new SolidColorBrush(Colors.Transparent); ...
    void Loaded(object sender, RoutedEventArgs e)
         
    {
    
        ContextMenu contextMenu = new ContextMenu();
        
            contextMenu.Background = new SolidColorBrush(Colors.Transparent);
                
        MenuItem item1 = new MenuItem();
              
        item1.Header = "红色";
                
        item1.Click += new RoutedEventHandler(item_Click);
                
        contextMenu.Items.Add(item1);
                
        MenuItem item2 = new MenuItem();
                
        item2.Header = "蓝色";
                
        item2.Click += new RoutedEventHandler(item_Click);
                
        contextMenu.Items.Add(item2);
                
        MenuItem item3 = new MenuItem();
                
        item3.Header = "绿色";
                
        item3.Click += new RoutedEventHandler(item_Click);
                
        contextMenu.Items.Add(item3);
                
        ContextMenuService.SetContextMenu(txtName, contextMenu);
             
    }
    
     
    
         
    void item_Click(object sender, RoutedEventArgs e)
            
    {
                
        MenuItem item = sender as MenuItem;
               
        //ContextMenu parent = item.Parent as ContextMenu;
                
        switch (item.Header.ToString())
                
        {
                    
            case "红色":
                        
            ellipse1.Fill = new SolidColorBrush(Colors.Red);
                        
            break;
                    
            case "蓝色":
                        
            ellipse1.Fill = new SolidColorBrush(Colors.Blue);
                        
            break;
                    
            case "绿色":
                        
            ellipse1.Fill = new SolidColorBrush(Colors.Green);
                        
            break;
                    
            default:
                        
            break;
                
        }
            
    }
    
     

     自己玩的简单右键菜单

    xaml

    <ListView.ContextMenu>
           <ContextMenu>
                 <MenuItem Header="下载" Click="MenuItem_Click" />
                 <MenuItem Header="打开" />
           </ContextMenu>
    </ListView.ContextMenu>


    c# 关于Ftp.FTPHelper,看另有一篇随笔很实用的FTP操作类

    private void MenuItem_Click(object sender, RoutedEventArgs e)
            {
                Ftp.FTPHelper("pic", "123456");
                Ftp.DownLoadFile(ftp://192.168.1.1/ + str, "e:\\" + str);
                System.Windows.Forms.MessageBox.Show("下载完毕");
            }

     再使用IsEnbled的属性,又一强暴功能

    转载于:https://www.cnblogs.com/Events/p/3326466.html

    展开全文
  • ContextMenu 类表示当用户在控件或窗体的特定区域上单击鼠标右键时会显示的快捷菜单,要想实现自定义的Menu和ContextMenu效果,大家可以通过派生ProfessionalColorTable类,下面小编把实现Menu和ContextMenu自定义...
  • ContextMenu Bug

    2020-12-09 07:43:05
    t get ContextMenu to work. <p>Error Message: 0x800a138f - JavaScript runtime error: Unable to get property 'namespaceURI' of undefined or null reference <p>Testing XAML: <pre><code> <text...
  • <div><p>As this example: ...bq0lx9 <p>Current: ...2. right click apple, close banana contextmenu and open apple contextmenu </p><p>该提问来源于开源项目:vkbansal/react-contextmenu</p></div>
  • Bibentrysource contextmenu

    2020-11-29 22:50:05
    <img width="102" alt="bibsource-contextmenu" src="https://img-blog.csdnimg.cn/img_convert/5329643935cfecf54171ebaf917dd013.png" /></p> <ul><li>[x] Change in CHANGELOG.md described</li><li>[ ] Tests ...
  • s behavior, when open a contextMenu should close other contextMenu, if not, multiple contextMenu is weird, see the following picture.(sorry for my poor English, hope you already understand) ...
  • <div><p>I have a dataTable with contextMenu and menuItem dynamically being shown/disabled or not in it. <p>More or less it looks like this: <p><code><p:dataTable id="dataTableId"> .....
  • <div><p>Adds <code>passDataset</code> property to contextmenu items: <pre><code>/** * Pass a selected node's dataset to an item's command. * * If this flag is set, when a contextmenu item ...
  • Contextmenu not working

    2020-12-01 12:30:02
    <div><p>I am trying to implement contextmenu on fancytree. I took reference from: ...
  • JavaFX Menu ContextMenu

    2020-07-09 21:01:19
    ContextMenu ContextMenu contextMenu = new ContextMenu(); MenuItem contextMenu1 = new MenuItem("contextMenu1"); MenuItem contextMenu2 = new MenuItem("contextMenu2"); MenuItem contextMenu3 = new ...

    ContextMenu

    ContextMenu contextMenu = new ContextMenu();
    MenuItem contextMenu1 = new MenuItem("contextMenu1");
    MenuItem contextMenu2 = new MenuItem("contextMenu2");
    MenuItem contextMenu3 = new MenuItem("contextMenu3");
    //MenuItem点击
    contextMenu1.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            System.out.println("contextMenu1.setOnAction");
        }
    });
    
    contextMenu.getItems().addAll(contextMenu1, contextMenu2, contextMenu3);
    button.setContextMenu(contextMenu);
    //ContextMenu弹出
    button.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
        @Override
        public void handle(ContextMenuEvent event) {
            System.out.println("button.setOnContextMenuRequested");
        }
    });
    
    
    展开全文

空空如也

1 2 3 4 5 ... 20
收藏数 5,325
精华内容 2,130
关键字:

contextmenu