无法在Android中的对话框中检测列表视图中的项目点击

时间:2016-10-15 15:22:16

标签: android xml android-layout listview

我试图检测点击Dialog内部的ListView项目,该项目从数组中获取元素。阵列工作正常,它正确显示我的结果,但是,当我尝试点击某个项目时,我没有收到任何反馈。

Java代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ListView
        android:id="@+id/list_view1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="1dp"
        android:padding="10dp" >
    </ListView>
</LinearLayout>

XML文件R.layout.dialog_editconstantformula

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/constid"
        android:textColorHint="#afafaf"
        android:textColor="#000"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_weight="1"
        android:layout_marginBottom="16dp"
        android:fontFamily="sans-serif"
        android:hint="Variable"
        />

    <EditText
        android:id="@+id/constvaluez"
        android:textColorHint="#afafaf"
        android:textColor="#000"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_weight="1"
        android:inputType="numberDecimal"
        android:layout_marginBottom="16dp"
        android:fontFamily="sans-serif"
        android:hint="Value"
        />

</LinearLayout>

R.layout.activity_view_calculator_formula

namelist = ["eric","lena","austin","booger"]
counter = 0
names = Hash.new

def start()
  puts "enter name"
  print "> "
  input = $stdin.gets.chomp
  namelist.push(input)
  more_names()
  hash_portion()
end

def more_names()
  puts "press 1 to add another name otherwise press 2 if you're done"
  print "> "
  choice = $stdin.gets.chomp

  if choice == 1
    puts "> "
    input1 = $stdin.gets.chomp
    namelist.push(input1)
    more_names()
  elsif choice == 2
    nil
  else
    more_names()
  end
end

def hash_portion()
  until counter == namelist.length do
    n_namelist = namelist.sample(1000000000000)
    n_namelist.each do |n|
      counter += 1
      names ["#{counter}"] = "#{n}"
    end
  end

  names.each do |digit,person|
    puts "#{digit}. #{person}"
  end
end

start()

0 个答案:

没有答案