position

Android List View Array Index Out Of Bounds Exception - No clues?

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have an app which loads a listview when opened, however I am getting an Array Index Out Of Bounds Exception, with no clues as to where the problem lies. It is trying to access index=-1 somewhere, but I have no idea where. The app loads Homework information from a database, puts them into separate Homework objects in an ArrayList and loads it into the ListView from there. I really don't know where the exception is coming from, I have checked all my code. There is only 1 homework in the list, however the app refuses to open and

GCC, stringification, and inline GLSL?

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'd like to declare GLSL shader strings inline using macro stringification: #define STRINGIFY ( A ) #A const GLchar * vert = STRINGIFY ( #version 120\n attribute vec2 position ; void main () { gl_Position = vec4 ( position , 0.0 , 1.0 ); } ); This builds and runs fine using VS2010 but fails to compile on gcc with: error : invalid preprocessing directive #version Is there a way to use stringification like this in a portable manner? I'm trying to avoid per-line quotes: const GLchar * vert = "#version 120\n" "attribute vec2 position;"

Correct placement of colorbar relative to geo axes (cartopy)

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Cartopy, I would like to have full control of where my colorbar goes. Usually I do this by getting the current axes position as basis and then create new axes for the colorbar. This works well for standard matplotlib axes but not when using Cartopy and geo_axes, because this will distort the axes. So, my question is: how do I get the exact position of my geo_axes? Here is a code example based on the Cartopy docs http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting.html : import cartopy.crs as ccrs import matplotlib

EditText's cursor position

匿名 (未验证) 提交于 2019-12-03 02:24:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Assuming, that a user has written some text into an EditText and thereafter touched somewhere else on the screen, which caused the cursor position to change: How can one determine the new cursor position? 回答1: The simple version: myEditText.getSelectionStart(); If you want to react on an event you may try myEditText.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { // view is myEditText here } }); event allows to distinguish between presses and releases. EditText also has a

Attempt to invoke virtual method 'void android.support.v4.view.ViewPager.setAdapter(android.support.v4.view.PagerAdapter)' on a null object reference

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to implement sliding tab layout using android material design. But it gives me NullPointerException . Here is my code so far: MainActivity.java public class MainActivity extends ActionBarActivity { private Toolbar toolbar; private ViewPager pager; private SlidingTabLayout nLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_appbar); toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); getSupportActionBar()

Creating custom simple cursor adapter

匿名 (未验证) 提交于 2019-12-03 02:19:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create a very simple cursor custom cursor adapter to facilitate changing the colors of row items on click. Using the following code private static int save = -1; public void onListItemClick(ListView parent, View v, int position, long id) { parent.getChildAt(position).setBackgroundColor(Color.BLUE); if (save != -1 && save != position){ parent.getChildAt(save).setBackgroundColor(Color.BLACK); } save = position; } I got the code from this thread https://stackoverflow.com/a/7649880/498449 I would have used a simple cursor adapter and

ByteBuffer: 图解ByteBuffer(转)

試著忘記壹切 提交于 2019-12-03 02:18:34
ByteBuffer前前后后看过好几次了,实际使用也用了一些,总觉得条理不够清晰。 《程序员的思维修炼》一本书讲过,主动学习,要比单纯看资料效果来的好,所以干脆写个详细点的文章来记录一下。 概述 ByteBuffer是NIO里用得最多的Buffer,它包含两个实现方式: HeapByteBuffer 是基于 Java 堆的实现,而 DirectByteBuffer 则使用了 unsafe 的API进行了堆外的实现。这里只说HeapByteBuffer。 使用 ByteBuffer最核心的方法是 put(byte) 和 get() 。分别是往ByteBuffer里写一个字节,和读一个字节。 值得注意的是,ByteBuffer的读写模式是分开的,正常的应用场景是:往ByteBuffer里写一些数据,然后flip(),然后再读出来。 这里插两个Channel方面的对象,以便更好的理解Buffer。 ReadableByteChannel 是一个从Channel中读取数据,并保存到ByteBuffer的接口,它包含一个方法: public int read(ByteBuffer dst) throws IOException; WritableByteChannel 则是从ByteBuffer中读取数据,并输出到Channel的接口: public int write(ByteBuffer

RecyclerView.getChild(index) shows null when list is scrolled (index gets messed up)

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been using SwipeableRecyclerView for my android application for enabling swipes for my recyclerView. RecyclerView contains a list of cardViews. I was trying to implement undo functionality for cards which will get deleted when swipe to left (first swipe shows undo, next swipe triggers delete) I am trying the following code (partially working I guess) SwipeableRecyclerViewTouchListener srvTouchListner = new SwipeableRecyclerViewTouchListener(rvTimerList, new SwipeableRecyclerViewTouchListener.SwipeListener(){ @Override public boolean

ViewPager inside ListView row prevents onItemClick to be fired

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a ViewPager inside every row of a ListView. It works fine, it changes the views inside it when the user use the swipe gesture, but it prevents the ListView's onItemClick method to be called. I know that the ViewPager is the culprit because when I hide it, the onItemClick is called, so this is what I am trying: I have created a ViewGroup to be the row (RowView). This ViewGroup has onInterceptTouchEvent overriden to avoid the ViewPager to handle further touch events when I detect a click. But the onItemClick callback is still not being

jquery scroll to specific div position in case of error and focus

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a hidden div with specific error messages throughout my form. Before form submit I run a validate routine to check if all the required fields are filled with some text. If not, a div with the class 'redAlert' gets visible right above the text field. I also want the dialog window to scroll right to this position when the error messages are displayed. I know there are quite a few plugins available for doing this but I want to do it using simple Jquery. I am trying to A) Find the first visible div with the class redAlert, b) Find its